dynamic sql query syntax
I need ur help with syntax of following dynamic sql.actually it is simple version of what am doing but i know for sure this line actually causing the error.
DECLARE @p_taskentrydtfilter nvarchar(50),@taskentrydttag nvarchar(100)
declare @p_taskentrydt DATETIME
set @p_taskentrydtfilter= '>='
set @p_taskentrydt = '20050609'
select @taskentrydttag=case when (@p_taskentrydt='' OR @p_taskentrydt is null) then '' else
' and task.entrydt '+
@p_taskentrydtfilter+''+@p_taskentrydt+''' and task.entrydt <'''+dateadd(d,1,@p_taskentrydt)+'' end
as u can see am storing a CASE stmt in a variable but it gives me error saying
"Syntax error converting datetime from character string."
any ideas .Thanks
Cheers

