| Home > SQL
Server Error Messages > Msg 121 - 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. |
| SQL
Server Error Messages - Msg 121 - 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. |
|
|
Error Message:
Server: Msg 121, Level 15, State 1, Line 4
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.
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 more 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] )
SELECT [FirstName], [LastName], [Gender]
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:
|
|
|