{"id":215,"date":"2012-05-17T05:40:38","date_gmt":"2012-05-17T05:40:38","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/05\/17\/the-select-list-for-the-insert-statement-contains-more-items-than-the-insert-list-the-number-of-select-values-must-match-the-number-of-insert-columns\/"},"modified":"2012-05-17T05:40:38","modified_gmt":"2012-05-17T05:40:38","slug":"the-select-list-for-the-insert-statement-contains-more-items-than-the-insert-list-the-number-of-select-values-must-match-the-number-of-insert-columns","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/05\/17\/the-select-list-for-the-insert-statement-contains-more-items-than-the-insert-list-the-number-of-select-values-must-match-the-number-of-insert-columns\/","title":{"rendered":"The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns."},"content":{"rendered":"

Error Message:<\/strong>
\n
\nMsg 121, Level 15, State 1, Line 3
\nThe select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns.
\n<\/font><\/p>\n

This error occurs when the select clause contains more number of columns then that present in the insert clause.<\/p>\n

Example:<\/strong>
\n[sql]
\nDECLARE @VTABLE table(ID INT, NAME VARCHAR(100))<\/p>\n

INSERT INTO @VTABLE(ID)
\nSELECT 1,’Devi’
\n[\/sql]<\/p>\n

Fix\/Resolution:<\/strong>
\nMake the number of columns in select statement and insert statement equal<\/p>\n

Update the select statement with the number of columns equal to that of insert statement.
\n[sql]
\nDECLARE @VTABLE table(ID INT, NAME VARCHAR(100))<\/p>\n

INSERT INTO @VTABLE(ID,NAME)
\nSELECT 1,’ABC’
\n[\/sql]<\/p>\n

Update the insert statement with the number of columns equal to that of select statement.
\n[sql]
\nDECLARE @VTABLE table(ID INT, NAME VARCHAR(100))<\/p>\n

INSERT INTO @VTABLE(ID)
\nSELECT 1
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"

Error Message: Msg 121, Level 15, State 1, Line 3 The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns. This error occurs when the select clause contains more number of columns then that present in the insert clause.…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1988,128],"tags":[1989,1990],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/215"}],"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=215"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}