Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

backup just a table

Posted on 2015-01-14
4
Medium Priority
?
66 Views
Last Modified: 2015-01-20
sql server 2012

a Developer wants to delete a table in our production database and then run a script to recreate it.
Is there a way to backup just a table in the database?
if not, recommendations on how to proceed with this?
0
Comment
Question by:jamesmetcalf74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Assisted Solution

by:Steve Wales
Steve Wales earned 1332 total points
ID: 40549701
Depending upon the size of the table, couldn't you just take a copy of it ?

select * into mytable_backup from mytable;

Now, you've got possible issues with updates that might occur while the data is being copied (if it's a highly volatile table) but at least you'll have your original ...
0
 

Author Comment

by:jamesmetcalf74
ID: 40549999
sorry I'm new to sql.

the two tables you referenced in your solution.

mytable_backup   is this a table you first create before you issue this command or is it created on the fly with the command.
0
 
LVL 23

Assisted Solution

by:Steve Wales
Steve Wales earned 1332 total points
ID: 40550065
The syntax "select * into mytable_backup" will create a new table on the fly based upon the results of the query.

It fails if the table already exists.
0
 
LVL 52

Accepted Solution

by:
Vitor Montalvão earned 668 total points
ID: 40550808
In SQL Server you can't backup only an object. You backup the full database.
For backup tables you can create a copy of it as mentioned above or export the data to a file. If you are going to change the table structure you should script the table before making the changes.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question