Server: Msg 137, Level 15, State 2, Line 3
Must declare the variable ‘@orderid’.
SQL Server allows to use variables in SQL scripts or statements. This error is raised when you refer to a variable without having it declared first.
The SQL statement cannot be parsed and further execution is stopped.
Error of the severity level 15 are generated by the user and can be fixed by the SQL Server user.
All versions of SQL Server.
WHERE OrderID = @orderid
To turn the above statement into a valid one, you would need to declare the variable @orderid prior to its use. Such as: DECLARE @orderid INT
SET @orderid = 10000
WHERE OrderID = @orderid Note that declaring a variable does not automatically assign some default value to that variable. This is different to some client programming languages. Declared variables which not yet have a value assigned are NULL.