Using SQL Server 2008 R2 I\'m trying to execute a stored procedure using exec with two parameters. The first parameter is an unique identifier. The second parameter can ei
I expected it to look something like this:
exec spAddCaseToDeletedInso @Case, (select case when dbo.getCaseOwnerByCaseId(@Case) = 1 then '3' else '2' end)
Your assumption is simply wrong. Check EXECUTE documentation
Execute a stored procedure or function
[ { EXEC | EXECUTE } ]
{
[ @return_status = ]
{ module_name [ ;number ] | @module_name_var }
[ [ @parameter = ] { value
| @variable [ OUTPUT ]
| [ DEFAULT ]
}
]
[ ,...n ]
[ WITH RECOMPILE ]
}
[;]
As you see you can pass as @parameter
:
So you need to use variable to hold result of function call and pass it to stored procedure.