krot

sql server if EXISTS

Mar 29th, 2018
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select
  2.  (SELECT 1 WHERE EXISTS(SELECT TOP 1 1 FROM nn n WHERE n.idNaa=x.idNaa)),
  3.  (CASE
  4.          WHEN EXISTS (SELECT TOP 1 1 FROM nn n WHERE n.idNaa=x.idNaa) THEN 1
  5.          ELSE 2
  6.        END )
  7. FROM cc x where idClient =3
RAW Paste Data