Monday, 26 August 2013

T-Sql condition check

T-Sql condition check

I have a table where there is column called allocated_to. If there is a
value in that column, that means the status of the row is assigned
otherwise unassigned.
From my search box i am sending 1 for assigned and 0 for unassigned. Also
I have two more similar checks for pending and closed on column named
SignOff (type: int).
Now we 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. For all records irrespective of any statuses.
So How do I add condition to my query. Actually its a change in SP and SP
for that is already up and running. So I cant make a huge change in my
query, by making it dynamic or whatsoever.
I can give you a sample here , how my query looks like:
If Some_Condition
begin
Select x,y,zfrom T1 join T2 on t1.a=t2.b
Where IsNull(SignOff,0)=@ParamForPendingAndClosed
end
Now I would like to add my above 9 check in this where, Any help??
Please note:
I can't take heavy alterations, as I need it to make in each and every
if-else condition. Query has almost 4-5 if else depending upon its header
condition, please do not suggest me to go for dynamic procedures. Other
than that are welcome.

No comments:

Post a Comment