SQLTeam.com | Weblogs | Forums

What is wrong with my Case statement

EXEC UpdateEmp
@id,
NULL,
NULL,
NULL,
NULL,
case @timeType when 1 then 0 else NULL end,
NULL,
0,
NULL,
44997,
NULL

You can't include a CASE in a stored proc call. You have to store the value in a variable and pass the variable to the EXEC.

DECLARE @timeType_for_EXEC bit
SET @timeType_for_EXEC = CASE @timeType WHEN 1 THEN 0 ELSE NULL END

EXEC UpdateEmp
@id, NULL, NULL, NULL, NULL,
@timeType_for_EXEC,
...
2 Likes