Database Snapshots

To create a database snapshot in SQL Server, you can use the CREATE DATABASE statement. A database snapshot provides a read-only, static view of a database, which can be useful for reporting, auditing, and data recovery purposes.

Here is an example of how you might create a database snapshot:

CREATE DATABASE Audit_Snapshot ON
(
    NAME = logical_file_name,
    FILENAME = 'os_file_name'
)
AS SNAPSHOT OF source_database_name;

In this example:

  • logical_file_name is the logical name of the database file from the source database.
  • os_file_name is the physical path where the snapshot file will be stored.
  • source_database_name is the name of the database you want to create a snapshot of.

For instance, if you want to create a snapshot of a database named MyDatabase, you would replace logical_file_name, os_file_name, and source_database_name with the appropriate values.

From my SQL Server DBA handbook.