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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 question

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2011-11-30 : 12:26:53
I am trying to insert data from one table to another using the insert to option, when i right click on the table then click script table as, then insert to query editor window using SQL Server, and when i type in the syntax:

select *
from dhmefm

I get the following error message:

Msg 121, Level 15, State 1, Line 1
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.

Can someone help me on this?

Roger DeFour

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-11-30 : 12:30:42
This is one reason that select * is bad. Does the table you're selecting from or to have an identity column? If so, remove those from your query.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

sandy123
Starting Member

14 Posts

Posted - 2011-11-30 : 13:05:06
Here is nice example.

http://www.sql-server-performance.com/2007/insert-statement-contains-more-items/

sandy
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-11-30 : 13:05:57
quote:
Originally posted by Trininole

I am trying to insert data from one table to another using the insert to option



You can DO that?

Don't use the GUI (SSMS? Right?)

Use a Query Window


and either use sp_help in grid mode for each and cut and paste or go to the catalog

MOO

Need more?





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -