Click here to Skip to main content
15,909,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
"IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='tbl_name' AND xtype='U') select * into ems_db1.dbo.Rish Master 3450_querysummary from ems_db1.dbo.querysummary where 1 = 0"

this query in c# it gives an error that Incorrect syntax near Master. In Rish Master 3450 spacing is there,is that case it gives an error? if yes then what is solution for this.

Rish Master 3450 is a value from textbox at runtime.
Posted
Updated 17-Nov-15 4:06am
v2
Comments
phil.o 17-Nov-15 10:17am    
where 1 = 0

What exactly are you expecting from this comparison? :)
Member 11922776 17-Nov-15 22:50pm    
it means that condition becomes false and only schema is selected not data.
[no name] 17-Nov-15 14:23pm    
As you mentioned ems_db1.dbo.Rish Master 3450_querysummary as table name right.
Member 11922776 17-Nov-15 22:50pm    
yes
[no name] 17-Nov-15 14:23pm    
i think table name is not allow spacing. Can you verify the table name is correct.

Use brackets:
SQL
...into ems_db1.dbo.[Rish Master 3450_querysummary] from...
 
Share this answer
 
Hi,

your sql query

SQL
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='tbl_name' AND xtype='U')
 select * into ems_db1.dbo.Rish Master 3450_querysummary from ems_db1.dbo.querysummary where 1 = 0


Try instead of your code

SQL
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='tbl_name' AND xtype='U')
select * into ems_db1.dbo.RishMaster3450_querysummary from ems_db1.dbo.querysummary where 1 = 0
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900