{"id":214,"date":"2012-05-17T05:27:08","date_gmt":"2012-05-17T05:27:08","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/05\/17\/the-select-list-for-the-insert-statement-contains-fewer-items-than-the-insert-list-the-number-of-select-values-must-match-the-number-of-insert-columns\/"},"modified":"2012-05-17T05:27:08","modified_gmt":"2012-05-17T05:27:08","slug":"the-select-list-for-the-insert-statement-contains-fewer-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-fewer-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 fewer items than the insert list. The number of SELECT values must match the number of INSERT columns."},"content":{"rendered":"
Error Message:<\/strong> This error occurs when the select clause contains lesser number of columns then that present in the insert clause.<\/p>\n Example:<\/strong> INSERT INTO @VTABLE(ID,NAME) Fix\/Resolution:<\/strong> Update the select statement with the number of columns equal to that of insert statement. INSERT INTO @VTABLE(ID,NAME) Update the insert statement with the number of columns equal to that of select statement. INSERT INTO @VTABLE(ID) Error Message: Msg 120, Level 15, State 1, Line 2 The select list for the INSERT statement contains fewer 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 lesser 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":[1985,128],"tags":[1986,1987],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-msg-120","category-sql-errors","tag-msg-120-level-15-state-1-line-3","tag-msg-120-level-15-state-1-line-3-the-select-list-for-the-insert-statement-contains-fewer-items-than-the-insert-list-the-number-of-select-values-must-match-the-number-of-insert-columns"],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/214","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=214"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\n
\nMsg 120, Level 15, State 1, Line 2
\nThe select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.
\n<\/font><\/p>\n
\n[sql]
\nDECLARE @VTABLE table(ID INT, NAME VARCHAR(100))<\/p>\n
\nSELECT 1
\n[\/sql]<\/p>\n
\nMake the number of columns in select statement and insert statement equal.<\/em><\/p>\n
\n[sql]
\nDECLARE @VTABLE table(ID INT, NAME VARCHAR(100))<\/p>\n
\nSELECT 1,’ABC’
\n[\/sql]<\/p>\n
\n[sql]
\nDECLARE @VTABLE table(ID INT, NAME VARCHAR(100))<\/p>\n
\nSELECT 1
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"