sql server - creating dynamic query in variable -


i creating dynamic query in sql server 2005 stored procedure , getting error if dates sent empty/null stored procedure that:

this input parameter cannot converted 

so, how check in stored procedure covert id date not empty: below query. have checked null in if condition showing me error

if @startdate not null , @enddate not null     begin            set @strcondition = ' fo.rf_date  >= convert(datetime, ''' + convert(varchar,@startdate,112) + ''') ,  fo.rf_date<= convert(datetime, ''' + convert(varchar,@enddate,112) + ''')'     end   

if can empty or null need exclude empty variables, e.g.

if nullif(@startdate, '') not null , nullif(@enddate, '') not null 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -