Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
declare @sql varchar(1000)
set @sql='select * from tblEvents where '+CONVERT (varchar(24),dateEventDate,113)+ '+'+''' '''+'+'+ CONVERT(varchar(20),timeStartTime)+'>='+(CONVERT(varchar(24),getdate(),113)) 

exec (@sql)


I am getting errors:

Msg 207, Level 16, State 1, Line 2
Invalid column name 'dateEventDate'.
Msg 207, Level 16, State 1, Line 2
Invalid column name 'timeStartTime'.

How can I solve this?
Posted
Updated 24-Nov-10 19:30pm
v2

1 solution

Because you SQL script(which you have posted here) doesn't contain the things dateEventDate & timeStartTime.

OR

you forgot to put the single quote for CONVERT() things.
below is working one
SQL
declare @sql varchar(1000)
set @sql='select * from tblEvents where '+'CONVERT (varchar(24),dateEventDate,113)'+ '+'+''' '''+'+'+ 'CONVERT(varchar(20),timeStartTime)'+'>='+'(CONVERT(varchar(24),getdate(),113))' 
exec (@sql)
 
Share this answer
 
v2
Comments
deepak thomas 25-Nov-10 1:55am    
thanks very much

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