"select * into table" Will it work for inserting data into existing table

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-04-22T04:37:56Z Indexed on 2010/04/22 4:43 UTC
Read the original article Hit count: 216

I am trying to insert data from one of my existing table into another existing table.

Is it possible to insert data into any existing table using select * into query. I think it can be done using union but in that case i need to record all data of my existing table into temporary table, then drop that table and finally than apply union to insert all records into same table

eg.

select * into #tblExisting from tblExisting
drop table tblExisting
select * into tblExisting from #tblExisting union tblActualData

Here tblExisting is the table where I actually want to store all data tblActualData is the table from where data is to be appended to tblExisting.

Is it right method. Do we have some other alternative ?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005