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
 select into existing table

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-08-28 : 17:53:59
Hello everyone

I know you have select * into a temp table.

But is there a way you can select into an existing table

Regards Rob

MCTS / MCITP certified

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-08-28 : 18:47:30
insert table_name
select ...

or

insert table_name(col1,col2,col3,...)
select col1,col2,col3,... from ...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-08-29 : 03:57:17
Using statement
select * into TempTable from MyTable
can only be done into non-existing table. Therefore statement "INTO TempTable" can be used only when there is no such table as TempTable.
Otherwise - if you have an existing table -, you need to use
insert TempTable (col1, col2) select col1, col2 from MyTable
. statement INTO TempTable can not be used in such premises.
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-08-29 : 06:30:00
SOrry what i meant was.

IS there a method you can select data from one permanent table into another permanent table.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-29 : 06:32:10
Yes, see webfred's post.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-08-29 : 06:33:59
ok thank you very much.

Just woken up. Lol sorry for being doppy

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-29 : 06:36:02
No problem.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -