Hi,
Check this...
SELECT *
FROM Table1
WHERE Column1 = CASE WHEN @para_Col1 <> '' then @para_Col1 ELSE Column1 End
AND Column2 = CASE WHEN @para_Col2 <> '' then @para_Col2 ELSE Column2 End
AND Column3 = CASE WHEN @para_Col3 <> '' then @para_Col3 ELSE Column3 End
AND Column4 = CASE WHEN @para_Col4 <> '' then @para_Col4 ELSE Column4 End
Update one...
@param1 nvarchar(max),
@param2 nvarchar(max)
SELECT *
FROM Table1
WHERE Column1 = CASE WHEN @param1 <> '' Then @param1 Else Column1 end
AND Column2 = CASE WHEN @param2 <> '' Then @param2 Else Column2 end
As per your conditions, you should develop a logic to identify whether "Select All" has been checked or not. On that basis you can customize your query as below.
@param1 nvarchar(max),
@param2 nvarchar(max),
SELECT *
FROM Table1
WHERE Column1 IN CASE WHEN @param1 = '1' then Cloumn1 else @param1 end
AND Column2 IN CASE WHEN @param2 = '1' then Cloumn2 else @param2 end
SELECT *
FROM Table1
WHERE Column1 IN CASE WHEN @param1 = 'Cloumn1' then Cloumn1 else @param1 end
AND Column2 IN CASE WHEN @param2 = 'Cloumn2' then Cloumn2 else @param2 end
Hope this will help you.
Cheers