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.
Example:
[sql]
DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))
INSERT INTO @VTABLE(ID)
SELECT 1,’Devi’
[/sql]
Fix/Resolution:
Make the number of columns in select statement and insert statement equal
Update the select statement with the number of columns equal to that of insert statement.
[sql]
DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))
INSERT INTO @VTABLE(ID,NAME)
SELECT 1,’ABC’
[/sql]
Update the insert statement with the number of columns equal to that of select statement.
[sql]
DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))
INSERT INTO @VTABLE(ID)
SELECT 1
[/sql]