monitor
#monitor#137

137

Product Name Event ID 137 Event Source MSSQLSERVER Component SQLEngine Sym

Product Name

Event ID

137

Event Source

MSSQLSERVER

Component

SQLEngine

Symbolic Name

P_SCALAR_VAR_NOTFOUND

Message Text

Must declare the scalar variable ”%.*ls”.

This error occurs when a variable is used in a SQL script without first declaring the variable. The

following example returns error 137 for both the SET and SELECT statements because

is not declared.

One of the more complicated causes of this error includes the use of a variable that is declared

outside the EXECUTE statement. For example, the variable

specified in the SELECT

statement is local to the SELECT statement; thus it is outside the EXECUTE statement.

Expand table

SET
@mycol =
'ContactName'
;
SELECT
@mycol;
USE
AdventureWorks2022;
GO