Msg 137, Level 15, State 2, Line 1. Must declare the scalar variable â@AuthorNameâ. Reason for this error: In the above example, the variable @AuthorName is used in the PRINT statement without declaring it, which is not allowed by Sql Server.