I've a situation where 4 parameters are passed to a stored procedure, on the basis of the existence of these parameters i need to modify the where condition of my select query.
Simply i can use IF-ELSE statement and write the select combinations in it.
Is there any way in sql to avoid this select combinations(all combinations with 4 parameters)?
Best Answer
Something like
This will probably run slower then using separate SELECTs separated by IF. However, you do have 16 permutation. So I'd probably combined both techniques: