sql server - T-Sql condition check -


i have table there column called allocated_to. if there value in column, means status of row assigned otherwise unassigned.

from search box sending 1 assigned , 0 unassigned. have 2 more similar checks pending , closed on column named signoff (type: int).

now have total of 9 search criteria

1. pending 2.closed 3. unassigned 4. assigned 5. pending + unassigned 6. pending + assigned 7. closed + unassigned 8. closed + assigned 9. records irrespective of statuses.  

so how add condition query. change in sp , sp , running. cant make huge change in query, making dynamic or whatsoever.

i can give sample here , how query looks like:

if some_condition  begin    select x,y,zfrom t1 join t2 on t1.a=t2.b    isnull(signoff,0)=@paramforpendingandclosed  end 

now add above 9 check in where, help??

please note:

i can't take heavy alterations, need make in each , every if-else condition. query has 4-5 if else depending upon header condition, please not suggest me go dynamic procedures. other welcome.

you add couple of optional parameters allow specify whether results should include pending/closed or assigned/unassigned results. way maintain single, flexible way of retrieving results.

take @ this answer overview of using optional parameters in sql.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -