您正在寻找的是异或(XOR):
-- Exclusive OR is an either/or combination which,
-- using => as "is defined as" symbol, can be shown as:
--
-- x XOR y => (x AND (NOT y)) OR ((NOT x) AND y)
-- x => @MyParam = MyCol
-- y => @MyParam IS NULL
-- DECLARE @MyParam NVARCHAR(32) = 'MC1,MC2'; -- returns two lines
-- DECLARE @MyParam NVARCHAR(32) = 'MC1'; -- returns one line
DECLARE @MyParam NVARCHAR(32) = NULL; -- returns one line
DECLARE @MyParamXML XML = N'<root><r>' + replace(@MyParam,',','</r><r>') + '</r></root>'
;WITH SOExample AS
(
SELECT cast('MC1' AS NVARCHAR(12)) AS MyCol, 'Line 1' AS MyCol2 UNION ALL
SELECT 'MC2' , 'Line 2' UNION ALL
SELECT NULL , 'Line NULL'
)
SELECT * from SOExample
WHERE
(@MyParam IS NULL AND ISNULL(MyCol,'<NULL Value>') = '<NULL Value>')
OR (@MyParam IS NOT NULL AND
SOExample.MyCol IN
(SELECT SSRSlist.MyParams.value('.','NVARCHAR(32)') as MyParam
FROM @MyParamXML.nodes('//root/r') as SSRSlist(MyParams)))