I ve following simple case statement
CASE WHEN @SPOID is not null THEN
(176)
ELSE
(SELECT designationID from setupdesignations where reportto = 99)
END
When else clause of this statement execute it gives me the following error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I am using this statement in the IN clause I was expecting multiple result to be returned in else case but it is giving me the above error. If I remove the case statement and execute the else part in query then i get the expected result
You can’t use a subselect as an expression within a CASE match, it expects a single value. Instead how about;