CompCodeBoy
Programmer
Having errors wheyn writing the quer below in Query Analyzer
Declare @strSQL varchar(1200)
Declare @datestr smalldatetime
set @strSQL= 'select * from table1 where date_field > ''12/12/2004'''
EXEC (strSQL)
The above works just fine. date_field is of type smalldatetime in table1
How I can get the above to work by replacing 12/12/2004 with @datestr ??? I tried casting and much more. Nothing seems to work. Any ideas?
Declare @strSQL varchar(1200)
Declare @datestr smalldatetime
set @strSQL= 'select * from table1 where date_field > ''12/12/2004'''
EXEC (strSQL)
The above works just fine. date_field is of type smalldatetime in table1
How I can get the above to work by replacing 12/12/2004 with @datestr ??? I tried casting and much more. Nothing seems to work. Any ideas?