Msg 141, Level 15, State 1, Line 3 A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.

Error Message:

Msg 141, Level 15, State 1, Line 3
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.

Sample Query:
[sql]
DECLARE @I INT
SELECT @I = ContactID,* FROM Person.Contact WHERE LastName = ‘Achong’
[/sql]

Resolution:
This error occurs when Column names and variable assignements occur a single select statement.
Move variable assignments and data-retrieval operations into seperate select statements
[sql]
DECLARE @I INT
SELECT @I = ContactID FROM Person.Contact WHERE LastName = ‘Achong’
SELECT * FROM Person.Contact WHERE LastName = ‘Achong’
[/sql]

Leave a Reply

Your email address will not be published. Required fields are marked *