If variable1 is null Select *from table Where condition1 And condition 2 And a is not null and b is not null Else Select * from table Where condition 1 And conditon 2 And a is null and b is null
How to write this as a dynamic SQL query since only the last 2 conditions change in 'if and else'?