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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 help with insert into

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2004-02-18 : 20:02:47

I've done this before, but its been awhile.. hopefully somebody can give me a refresher on this one. I have created a table which has the same table structure as another table. I want to insert all the rows that I select from the source table, into the new empty table. There's about 30 columns.

Whats the best way to do this?

Thanks alot

mike123

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-02-18 : 20:20:44
Hi Mike

INSERT INTO Table2 (col1, col2, col3 etc)
SELECT col1, col2, col3 etc
FROM Table1

You have to specify all the columns, but a nice shortcut to stuff like this is "Exec sp_help Table1" in query analyzer will return them all for you.



Damian
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2004-02-18 : 22:25:55

thanks again damian !
Go to Top of Page
   

- Advertisement -