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.

Example:
[sql]
DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID,NAME)
SELECT 1
[/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]

Leave a Reply

Your email address will not be published. Required fields are marked *