http://msdn.microsoft.com/en-us/library/aa258711Error 137 SQL Server 2000 Error 137 Severity Level 15 Message Text Must declare the variable '%.*ls'.Explanation This error occurs when a variable is used in a SQL script without first declaring the variable. This example returns error 137:SET @mycol = 'ContactName' SELECT @mycol GO One of the more complicated causes of this error includes the use of a variable that was declared outside the EXECUTE statement. For example:USE Northwind GO DECLARE @mycol nvarchar(20) SET @mycol = 'ContactName' EXECUTE ('SELECT @mycol FROM Customers') Action Verify that any variables used in a SQL script are declared before being used elsewhere in the script.Rewrite the procedure so that it does not reference variables in the EXECUTE statement that were declared outside of it.USE Northwind GO DECLARE @mycol nvarchar(20) SET @mycol = 'ContactName' EXECUTE ('SELECT ' + @mycol + ' FROM Customers')
http://wenku.baidu.com/view/9e82fe768e9951e79b8927f7.html
SQL Server 2000 Error 137
Severity Level 15
Message Text
Must declare the variable '%.*ls'.Explanation
This error occurs when a variable is used in a SQL script without first declaring the variable. This example returns error 137:SET @mycol = 'ContactName'
SELECT @mycol
GO
One of the more complicated causes of this error includes the use of a variable that was declared outside the EXECUTE statement. For example:USE Northwind
GO
DECLARE @mycol nvarchar(20)
SET @mycol = 'ContactName'
EXECUTE ('SELECT @mycol FROM Customers')
Action
Verify that any variables used in a SQL script are declared before being used elsewhere in the script.Rewrite the procedure so that it does not reference variables in the EXECUTE statement that were declared outside of it.USE Northwind
GO
DECLARE @mycol nvarchar(20)
SET @mycol = 'ContactName'
EXECUTE ('SELECT ' + @mycol + ' FROM Customers')