sql server - Add column to condition based on parameter value SQL -


i'm working in dynamic query need add column query if parameter value false.

//sql:

set @filterexp = 'select * tblname ptblnflag = '+convert(varchar(2),@blnflag)+') tbl 1=1'+ coalesce(nullif( convert(varchar(8000), @filterexp),''), '') 

in above query need check if @blnflag false column can added in condition. if true need not there.

something if condition false should return values , if true result set based on condition.

you need and/or operator's no need of dynamic query here

select *   tblname  ( ptblnflag = @blnflag          , @blnflag = 0 )         or @blnflag = 1  

may wrong variable names logic same


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -