Pages

Monday, June 2, 2014

If variable is blank then no where clause

use OR:
select * from yourTable
where @test = '' OR Agent = @test
if @test coming with null value (instead of ''), you must use:
select * from yourTable
where @test is null OR Agent = @test
And
case when @Status = 1 then tbl1.Status end != 'Done' Or
case when @Status = 2 then tbl1.Status end = 'Done' 

No comments:

Post a Comment