A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations. – SQLSERVERLEARNER https://sqlserverlearner.com LEARN SQL SERVER ONLINE Fri, 08 Jun 2012 08:20:25 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 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. https://sqlserverlearner.com/2012/06/08/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/ https://sqlserverlearner.com/2012/06/08/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/#respond Fri, 08 Jun 2012 08:20:25 +0000 https://sqlserverlearner.azurewebsites.net/2012/06/08/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]

]]>
https://sqlserverlearner.com/2012/06/08/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/feed/ 0