Error 137

Severity Level 15

Message Text

Must declare variable '%.*s'.

Explanation

This error occurs when variables that were declared outside of the EXECUTE statement are not available to the command being executed.

For example, this procedure will produce error 137:

declare @mystr char(50)
select @mystr="abc"
exec ("select @mystr")

Action

Rewrite the procedure so that it does not reference variables in the EXECUTE statement that were declared outside of it.