{"id":249,"date":"2012-06-08T08:20:25","date_gmt":"2012-06-08T08:20:25","guid":{"rendered":"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\/"},"modified":"2012-06-08T08:20:25","modified_gmt":"2012-06-08T08:20:25","slug":"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","status":"publish","type":"post","link":"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\/","title":{"rendered":"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."},"content":{"rendered":"

Error Message:
\n
\nMsg 141, Level 15, State 1, Line 3
\nA SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
\n<\/font><\/p>\n

Sample Query:
\n[sql]
\nDECLARE @I INT
\nSELECT @I = ContactID,* FROM Person.Contact WHERE LastName = ‘Achong’
\n[\/sql]<\/p>\n

Resolution:
\nThis error occurs when Column names and variable assignements occur a single select statement.
\nMove variable assignments and data-retrieval operations into seperate select statements
\n[sql]
\nDECLARE @I INT
\nSELECT @I = ContactID FROM Person.Contact WHERE LastName = ‘Achong’
\nSELECT * FROM Person.Contact WHERE LastName = ‘Achong’
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"

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…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2146],"tags":[2147,2148,2149,2150],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-msg-141","tag-a-select-statement-that-assigns-a-value-to-a-variable-must-not-be-combined-with-data-retrieval-operations","tag-msg-141","tag-msg-141-level-15-state-1","tag-msg-141-level-15-state-1-line-3"],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}