concept snapshot in category sql

appears as: Snapshots, snapshots, snapshot, Snapshot
SQL Server MVP Deep Dives Vol. 2

This is an excerpt from Manning's book SQL Server MVP Deep Dives Vol. 2.

Most storage arrays support snapshots, which are much like the snapshot technology introduced in Microsoft SQL Server 2005. Snapshots allow you to create a point-in-time view of a LUN, which can then be presented to another server for a variety of purposes (such as backups or QA testing). Although the technique used by storage arrays is similar to the one used by SQL Server, the snapshots aren’t compatible with SQL Server. These array-level snapshots won’t show up in the database snapshot menu tree of SQL Server Management Studio, nor can they be queried for using the SQL Server dynamic management views.

A similar method is called copy on first write. With this technique, after a snapshot is taken the first time a write is made to the disk, the block is copied to the snapshot space (which was predefined on the storage array). A pointer within the snapshot’s configuration is updated to show that the snapshot should look at the block within this space instead of the original block (which the source volume continues to use).

SQL Server MVP Deep Dives

This is an excerpt from Manning's book SQL Server MVP Deep Dives.

In SQL Server 2005, Microsoft added in something called SNAPSHOT isolation level. In SNAPSHOT isolation level, when you start a transaction, all the data you read will look exactly as it did when you started the transaction. Currently executing processes don’t lock you out; they maintain the previous version for anyone who wants to see it. This is a nifty way to implement a system, but it presents some difficulties for modifying data—you really have to consider how the SNAPSHOT isolation level will affect your queries and applications. SNAPSHOT transaction isolation uses row versioning to store the before image of the data in tempdb, so fully understanding the impact on your hardware is very important.

All of this leads us to a database setting called READ_COMMITTED_SNAPSHOT that will change the way the default READ COMMITTED isolation behaves. This setting uses SNAPSHOT isolation level at a statement level, so the results you get for a query will only include rows that have been committed; but if someone changes the data after you start getting results, you won’t see that. This is generally good enough locking, and it is certainly enough if you are using optimistic locking techniques to protect users from overwriting other users’ changes.

Another example that exists in the public domain but is not yet in BOL is also available. If your distributor is SQL Server 2005, the Snapshot Agent has an undocumented /NoBcpData switch that will allow you to generate a snapshot without any BCP data. This can be useful when you need to (quickly) debug schema problems generated on initialization.