Can anyone tell me the correct syntax to do this or even if it will work. I'm using SQL Server 2005. It compiles but when it runs I get this error:
"Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."
I got around it by doing the following, but eventually there could be more than two other options.
"Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."
Code:
ReferralTypeID IN (
CASE
WHEN @OnlyNCFCH = 'True' THEN 4 --NC-FCH
ELSE (SELECT ReferralTypeID FROM zReferralType WHERE ReferralTypeID <> 4)
END)
I got around it by doing the following, but eventually there could be more than two other options.
Code:
(ReferralTypeID =
CASE
WHEN @OnlyNCFCH = 'True' THEN 4 --NC-FCH
ELSE 1 --FC
END OR ReferralTypeID =
CASE
WHEN @OnlyNCFCH = 'True' THEN 4 --NC-FCH
ELSE 6 --FO
END)