I need a stored procedure which can filter data based on multiple parameters. Say there are 4 parameters(A,B,C & D). The user can select any number of them. Like they can select only A or A & C or all 4.
For example:
If the user selects only A, then it should be like:
select Col1, Col2, Col3, Col4, Col5 from tbl1 where A = 123
If the user selects parameters B & D, then it should be like:
select col1, col2, col3, col4, col5 from tbl1 where B = 'final' and D = '1'
How to write such a dynamic query with a where clause where the conditions change as per the selection?