clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
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. 582680 fiddles created (13279 in the last week).

create table a (col int);
 hidden batch(es)


create table b (col int);
 hidden batch(es)


create table c (col int);
 hidden batch(es)


insert into c (col) values (1), (2) ;
2 rows affected
 hidden batch(es)


create table d (col int);
 hidden batch(es)


insert into d (col) values (null) ;
1 rows affected
 hidden batch(es)


DECLARE @prm int; SET @prm = 2 ; SELECT CASE WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM a) THEN 'tableA' WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM b) THEN 'tableB' WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM c) THEN 'tableC' --- WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM d) THEN 'tableD' ELSE 'Not Found' END AS result ;
result
tableC
 hidden batch(es)


DECLARE @prm int; SET @prm = NULL ; SELECT CASE WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM a) THEN 'tableA' WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM b) THEN 'tableB' WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM c) THEN 'tableC' --- WHEN EXISTS (SELECT @prm INTERSECT SELECT col FROM d) THEN 'tableD' ELSE 'Not Found' END AS result ;
result
tableD
 hidden batch(es)