DECLARE @SubDesc1 nvarchar(100)
SET @SubDesc1 = null
I would like to do something like that.
Query 1
SELECT *
From Table1
where Category = 'Category1'
AND [Description] ='ABC'
AND SubDescription1 IS NULL
OR SubDescription1 = @SubDesc1
Query 2
SELECT *
FROM Table1
WHERE Category = 'Category1'
AND [Description] ='ABC'
AND SubDescription1 = (Case WHEN @SubDesc1 IS NOT NULL
Then @SubDesc1
ELSE SubDescription1
END)
None of them solved if my @SubDesc1 = 'def'
However, it will get me both records where SubDescription1 Is null
and SubDescription1 = 'def'
How can I do this?