Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

Best way to do this? (DB related)

This topic is 4671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am using MS SQL. Recently I deleted a bunch of rows from a table, but before doing so backed up the database. Now, a few days later, it turns out I want to restore those rows from that able that I deleted. However we can't just simply roll-back the DB to the restore point, as new data has been added since then. So, what is the easiest way to grab all the data from the one table in the backed up DB, and copy that into the current DB? I have no clue on how to do this.. The only way I can think of is: -copy the old .mdf and .ldf files from the backed up DB -attach the database to a different named DB -do something like insert into table(foo,bar) values(select 'foo' from other_database.table,select bar from other_database.table) However, this won't work for several reasons. First of all, the backup of the DB is NOT just a copy of the raw .mdf and .ldf file, but rather a backup made using Enterprise Manager... second of all, obviously that insert / select statement won't work as is... Thanks a lot for any help.

Share this post


Link to post
Share on other sites
Advertisement
How I would do it:

1. Restore backup into a new database
2. Make duplicate of live database to merge with
3. Do the copy as you said ... insert into Duplicate_Database.whatever ... where Earlier_Delete_Criteria
4. Verify that it actually restored the lines you wanted. If it didn't, drop the duplicate database and restart from step two.
5. Stop live use of the database, if reasonable and proper for the situation
6. Back up live database again
7. Begin a transaction
8. Do the insert that worked proplery in step 4
9. Verify that the results are correct. If it failed, rollback and start over. If it worked, commit the transaction.
10. Resume live use of the database, if stopped in step 5.


frob.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!