SQL Server 2005: Restoring Data to a Table with an ID column

I deleted some data from a table today that I shouldn't have. With a few steps in SQL Server Management Studio, I was able to recover the data.

  1. Restore Database Backup (of course you have automated backups)

    1. Right Click Database -> Tasks -> Restore -> Database

    2. Select From device:

    3. Find the .bak file

    4. Follow the prompts



  2. Export data from source table to destination table

    1. Right Click Database -> Tasks -> Export Data...

    2. Fill in the source database / server. Next.

    3. Fill in the destination database / server. Next.

    4. Choose Write a query to specify data to transfer. Next.

    5. Enter the query for data you want to copy. Next.

    6. For Destination select the target table. Next.

    7. Click the Edit button in the Mapping column. OK.

    8. Check the Enable Identity Insert column. OK.

    9. Preview, etc, and run (Next, Next, Finish, etc)




0 comments: