有兩個變量StatusTypeTestID和StatusTestID希望將它們設置爲可選的where子句,如下圖所示,但可選選項不適用於int變量。如何設置int類型變量的可選參數
注:int變量默認值爲0
DECLARE @StatusTypeTestID as int
SET @StatusTypeTestID = 1
DECLARE @StatusTestID as int
SET @StatusTestID = 0
select *
from LiveCustomerStatus
where ([email protected]
and (Status = @StatusTestID or @StatusTestID is null))