Msg 137, Level 15, State 2, Line 1 Must declare the scalar variable "@EmployeeName".  

  RSS

Anurag jain
(@anurag-jain)
New Member Registered
Joined: 11 months ago
Posts: 1
20/07/2018 11:47 am  

Hi,

I get this error again and again when i want to execute my statement:-

PRINT @EmployeeName

Msg 137, Level 15, State 2, Line 1
Must declare the scalar variable "@EmployeeName".

Please give me best solution

thanks


ReplyQuote
TechGroup Admin
(@admin)
Eminent Member Admin
Joined: 1 year ago
Posts: 11
20/07/2018 12:05 pm  

In your example, the variable @EmployeeName is used in the PRINT statement without declaring it, which is not allowed by Sql Server.

Solution:Declare the @EmployeeName variable before using it in the PRINT statement as below:

DECLARE @EmployeeName VARCHAR(50) = 'Rahul Verma'
PRINT @EmployeeName


ReplyQuote
Share:
  
Working

Please Login or Register