Home | User-Defined Functions | Tips & Tricks | SQL Server 2005 | SQL Server 2008 | Forums | FAQ | Practice Test |    
Home > SQL Server Error Messages > Msg 120 - 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.
SQL Server Error Messages - Msg 120 - 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.

SQL Server Error Messages - Msg 120

Error Message:

Server: Msg 120, Level 15, State 1, Line 4
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.

Causes:

As the error message describes, this error occurs when doing an INSERT to a table using the INSERT INTO … SELECT FROM format and the number of columns specified in the SELECT clause is less than the number of columns specified in the INSERT clause.

To illustrate, the following INSERT statement will generate the error:

INSERT INTO [dbo].[Employees] ( [FirstName], [LastName], [Gender] )
SELECT [FirstName], [LastName]
FROM [dbo].[Applicants]

Solution/Workaround:

To avoid this error, make sure that the number of columns specified in the SELECT clause matches the number of columns specified in the INSERT INTO clause:

INSERT INTO [dbo].[Employees] ( [FirstName], [LastName], [Gender] )
SELECT [FirstName], [LastName], [Gender]
FROM [dbo].[Applicants]

Related Topics: