I have got a stored procedure which has five parameters. I want to include them in where clause as follows
- If parameter is not null then include it in query as an IN clause
That is, parameter value can be like 'Test' or 'Test,Best' etc. I'm converting this comma seperated values into table using function in SQL.
I tried to use COALESCE(@test,test_column) = test_column
but i'm unable to include IN clause here (What if @test = 'Test,Best').
So, i want to do something like mentioned below
DECLARE @param varchar(max) = 'Test,Best';
Select * from table where CASE when @param is not null then table.column in (@param)
Any suggestions please.