Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
apshathish
Starting Member
2 Posts |
Posted - 2012-10-23 : 09:19:27
|
Hi,I am facing below error. Could someone please help on this.?Msg 121, Level 15, State 1, Line 1The 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.Below is the query.INSERT INTO dbo.table3 (ID, Value)select * from dbo.table1inner join dbo.table2on dbo.table1.ID = dbo.table2.IDReason is while retrieving data am getting below result set.Note : ID and Value are column name.ID Value ID Value1 First 1 First2 Second 2 Second3 Third 3 ThirdBut it should be single, I mean ID and value column only should come. So it would be great if someone can help for me.S |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-10-23 : 09:27:28
|
INSERT INTO dbo.table3 (ID, Value)select table1.ID, table1.Value from dbo.table1inner join dbo.table2on dbo.table1.ID = dbo.table2.ID Too old to Rock'n'Roll too young to die. |
|
|
prett
Posting Yak Master
212 Posts |
Posted - 2012-10-26 : 04:57:55
|
This error occurs when the number of columns specified in the SELECT clause is more than the number of columns specified in the INSERT clause.INSERT INTO [dbo].[Employees] ( [FirstName], [LastName] )SELECT [FirstName], [LastName], [Gender]FROM [dbo].[Applicants]In this case, you will get this error message:Msg 121, Level 15, State 1, Line 1The 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.As can be seen from the INSERT INTO ... SELECT statement, there are 3 columns specified in the SELECT clause but only 2 columns are specified in the INSERT INTO clause. |
|
|
|
|
|
|
|