A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations
We declare local veriables :
As
Begin
Declare
@Name Varchar(max),
@Place varchar(max),
@id int
select @Name =Name, EmployeeId from Employee where EmployeeId=@EmployeeId --This generates the above error.
Region behind this is: Employee also expects local veriable to be assigned to it.
correct one :
select @Name =Name, @id =EmployeeId from Employee where EmployeeId=@EmployeeId
similaryly @Name= Name and Name=@Name matters.
assigning a value from a table to a variable @Name= Name.
giving a value to a table column Name=@Name ... if mistake in this will give null result.so be careful.

Comments
Post a Comment