declare @flagAll = 1;In this example if the @flagAll is set to 1, then the first condition will be satisfied so the second condition will not be executed as it is OR condition, so all data will be returned. Else if @flagAll = 0 then the first condition will be failed, as it is OR condition the second condition S.Department = 'CSE' will be considered and all CSE department Student data will be returned.
Select *
from Students S
where @flagAll = 1
or S.Department = 'CSE'
If you have alternate solution, Kindly post as comment.
No comments:
Post a Comment