SELECT
CASE
WHEN Count(*) = 0 THEN EXEC Proc1
WHEN Count(*) > 0 THEN EXEC Proc2
END
FROM Table1
WHERE Table1.flag = 'Y'
As the count is dictating the flow, then use a variable
i.e.
DECLARE @v_Count bigint
SELECT Count = Count(*)
FROM Table1
WHERE Table1.flag = 'Y'
If @v_Count = 0
THEN EXEC Proc1
ELSE Exec Proc2
I think it should do the same thing as you are asking.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.