I wrote a blog earlier, on Database Snapshots which explained about Database Snapshots, steps to create Database Snapshots and some points to remember when working with them. Before continuing reading this blog, I would recommend you read that blog here… Introduction to Database Snapshots in SQL Server
In this blog we shall look at a simple task of restoring data from a Database Snapshots in case if a table is deleted accidentally.
I would recommend you to use the scripts that are available in the earlier blog mentioned above to create the database snapshot and the tables used in this blog. We start this process by dropping a table and assume that, this has happened as an unforeseen event (accidentally dropping a table, in other words, dropping a table instead of dropping an actual one).
Once that table is dropped, our next step is to create the same table and bring in the data from one of the most recent Database Snapshots. In order to do this I am using the SELECT INTO statement as shown below.
To confirm whether or not the table has got the data back, we run the SELECT command on the table we created and populated data, in the previous step.
In this way Database Snapshots can also be used an alternate mechanism of Disaster Recovery for unforeseen events such as accidental dropping, truncating or updating of data.
*** Note: You cannot retrieve entire data from a database snapshot table, since it contains only the data in the table at the point of creation of the database snapshot. Any new data that has been inserted, updated, modified or deleted after the creation of the database snapshot cannot be retrieved.
Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.