DECLARE @SubDesc1 nvarchar(100)
SET @SubDesc1 = null
我想做这样的事情。
查询 1
SELECT *
From Table1
where Category = 'Category1'
AND [Description] ='ABC'
AND SubDescription1 IS NULL
OR SubDescription1 = @SubDesc1
查询 2
SELECT *
FROM Table1
WHERE Category = 'Category1'
AND [Description] ='ABC'
AND SubDescription1 = (Case WHEN @SubDesc1 IS NOT NULL
Then @SubDesc1
ELSE SubDescription1
END)
如果我的,他们都没有解决@SubDesc1 = 'def'
但是,它会让我记录在哪里SubDescription1 Is null
和SubDescription1 = 'def'
我怎样才能做到这一点?