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
 backing up and restoring a Table

Author  Topic 

jpotucek
Constraint Violating Yak Guru

273 Posts

Posted - 2007-04-27 : 14:24:24
What is the best way (short of backing up the entire DB) to make a copy of a Table so that It can be easily restored. We have a table that we want to make some serious changes to, but I want to make sure I can restore if if I need to (if the changes don't work)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-27 : 14:35:30
Here's what I do:

SELECT *
INTO SomeNewTable
FROM YourTable

This doesn't copy over any constraints, indexes, or triggers. So if you want to save those too, then you should script them out and put them on SomeNewTable.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jpotucek
Constraint Violating Yak Guru

273 Posts

Posted - 2007-04-27 : 14:54:49
THANKS! Then basically if I needed to restore the table, I could run the script to drop and recreate it and then copy the data back in??
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-27 : 15:05:30
Or you could just rename it to do the "restore".

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -