Quantcast
Channel: SQL Errors – SQLSERVERLEARNER
Viewing all articles
Browse latest Browse all 74

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.

$
0
0

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:

DECLARE @I INT
SELECT @I = ContactID,* FROM Person.Contact WHERE LastName = 'Achong' 

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

DECLARE @I INT
SELECT @I = ContactID FROM Person.Contact WHERE LastName = 'Achong' 
SELECT * FROM Person.Contact WHERE LastName = 'Achong' 

Viewing all articles
Browse latest Browse all 74

Trending Articles