Monday, February 20, 2012

Move data out of a table

I need to move certain rows out of a table into a temporary table then pull them back in.

These tables are designed by a third party, and have triggers which unfortunately only work on new records.

So I need to create a new temp table with the same sturcture as the first one, move the selected records into the new table, then pull them back in...

any ideas
thanks guys

dbforums has been a great helphow about

select * into #Tmp from <your 3rd party table> where <youer where clause>.

This will produce a temp table close enough if not exactly like the original. There are a few things that could prevent an exact duplicate structure but I would not be conserned.

If you need to create an empty table first then select * into #Tmp from <your 3rd party table> where 1=2.

No comments:

Post a Comment