clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2335725 fiddles created (27457 in the last week).

CREATE TABLE T ([欄位A] nvarchar(1)) ; INSERT INTO T ([欄位A]) VALUES ('0'), ('1'), ('2'), ('3'), ('4') ;
5 rows affected
 hidden batch(es)


/* 當 @參數A ='' 欄位A顯示 0 1 2 3 4 @參數A ='0' 欄位A顯示 1 2 3 4 @參數A ='1' 欄位A顯示 0 */ declare @參數A nvarchar(1) = '1'; select * from T where [欄位A] like case @參數A when '' then '[0|1|2|3|4]' when '0' then '[1|2|3|4]' when '1' then '0' end
欄位A
0
 hidden batch(es)