how to insert into a table from a query
-
Thursday, February 14, 2013 11:40 PM
I have two tables with identical structures. One table has the historical records and one is the current, in use table with only a couple thousand records.
I would like a query something like this,
insert into myHistoricalTable (select * from recentTable where uniqueCol = 'TAS')
But I am pretty sure I can't do this in this way.
How might I do this?
All Replies
-
Thursday, February 14, 2013 11:48 PM
Similar question was asked this morning -
http://social.msdn.microsoft.com/Forums/en/transactsql/thread/3809a50d-dc67-4690-bf2a-e7909ec456f3
Example -
INSERT INTO DB.SchemaName.myHistoricalTable (Col1,Col2...) SELECT Col1,Col2... FROM DB.SchemaName.recentTable WHERE uniqueCol = 'TAS'
Narsimha
- Marked As Answer by danielsn Friday, February 15, 2013 12:03 AM
-
Friday, February 15, 2013 12:04 AM
Sweet, thanks.
I did look for similar posts with the search, but didnt just look through the last ones.

