Creating a SQL Server database snapshot takes a single T-SQL statement and less than a minute to execute. A snapshot captures the state of a database at a specific point in time, giving you a fast, low-overhead rollback option without the complexity of a full backup and restore cycle. If something goes wrong during a major upgrade, data import, or schema change, you can revert the entire database to the snapshot state in minutes rather than hours.
What Is a SQL Server Database Snapshot?
A database snapshot is a read-only, static view of a source database at the moment the snapshot was created. It lives on the same SQL Server instance as the source database and uses a sparse file mechanism to store only the pages that have changed since the snapshot was taken. This is called copy-on-write. When a page in the source database is modified for the first time after the snapshot exists, SQL Server writes the original page to the snapshot file before applying the change. The snapshot itself never grows beyond the volume of changed data.
This is fundamentally different from a backup. A backup is a separate copy of the entire database stored for recovery purposes. A snapshot is a lightweight, point-in-time reference that stays in sync with the source database through that copy-on-write mechanism. You can query a snapshot directly, which makes it useful for reporting against a stable dataset while the production database continues to be updated.
When Should You Use a Database Snapshot?
Database snapshots are not a replacement for your backup and recovery strategy. They depend entirely on the source database being online and intact. If the source database is lost or corrupted, the snapshot is useless. That said, there are several scenarios where snapshots deliver real operational value.
Before a high-risk change. Any time you're about to run a major data import, execute a complex schema migration, or apply an upgrade script that you're not 100% confident about, create a snapshot first. Reverting to a snapshot is significantly faster than restoring from a backup, often completing in under a minute for smaller databases. For large databases, revert time scales with the volume of changed pages, not the total database size.
Reporting on a mirrored database. In a database mirroring setup (legacy, but still present in many environments), the mirror database is normally inaccessible. Creating a snapshot of the mirror lets you run read queries against a consistent view of the data without touching the principal. This was a common pattern before Always On Availability Groups became the standard approach.
Audit and reconciliation work. If you need to compare the state of data before and after a batch process, a snapshot gives you a stable baseline to query against. You can join tables in the snapshot to the live database to identify exactly what changed.
Development and testing. Snapshots let developers test destructive operations against a production-like dataset and roll back instantly. This is far quicker than restoring a backup copy.
How to Create a SQL Server Database Snapshot
The syntax is straightforward. You need to know three things before you run the command: the name you want to give the snapshot, the logical name of the data file in the source database, and a file path for the snapshot file itself.
To find the logical file name of your source database, run this first:
SELECT name, physical_name
FROM sys.database_files;
Run this in the context of the source database. The name column gives you the logical name you'll need for the snapshot command.
Once you have that, create the snapshot:
CREATE DATABASE YourSnapshotName
ON (NAME = 'LogicalDataFileName', FILENAME = 'D:\Snapshots\YourSnapshotName.SNP')
AS SNAPSHOT OF YourSourceDatabase;
Replace YourSnapshotName with a descriptive name that includes the date and time, for example SalesDB_Snapshot_20250615_1400. Replace LogicalDataFileName with the logical name from the query above. The FILENAME path must exist on the server and the SQL Server service account must have write access to it.
If your database has multiple data files, you need to include an entry for each file in the ON clause:
CREATE DATABASE YourSnapshotName
ON
(NAME = 'LogicalDataFileName1', FILENAME = 'D:\Snapshots\YourSnapshotName_1.SNP'),
(NAME = 'LogicalDataFileName2', FILENAME = 'D:\Snapshots\YourSnapshotName_2.SNP')
AS SNAPSHOT OF YourSourceDatabase;
Log files are not included in snapshots. SQL Server handles this automatically.
How to Revert a Database to a Snapshot
If something goes wrong and you need to roll back, the revert command is equally simple:
RESTORE DATABASE YourSourceDatabase
FROM DATABASE_SNAPSHOT = 'YourSnapshotName';
Before running this, make sure no other users are connected to the source database. The revert operation requires exclusive access. You can force this by setting the database to single-user mode first:
ALTER DATABASE YourSourceDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE YourSourceDatabase
FROM DATABASE_SNAPSHOT = 'YourSnapshotName';
ALTER DATABASE YourSourceDatabase SET MULTI_USER;
The revert undoes all changes made to the source database since the snapshot was taken. It's a hard reset to that point in time. Any data written after the snapshot was created is gone.
What to Watch Out For
A few practical cautions from real-world use:
Snapshot files grow over time. As more pages change in the source database, the snapshot file grows. If you leave a snapshot in place for days during a busy period, the file can become very large. Monitor disk space on the snapshot drive. Running out of space will cause the snapshot to become suspect and could impact the source database.
You can only revert to the most recent snapshot. If you have multiple snapshots of the same database, you must drop the newer ones before reverting to an older one. Plan your snapshot naming and management accordingly.
Snapshots are not supported on all database configurations. You cannot create snapshots on databases using the simple recovery model if they contain filestream data, on databases with certain mirroring states, or on system databases (with the exception of model in specific scenarios). Check the Microsoft documentation for the full list of restrictions.
Performance impact is real but usually minor. The copy-on-write mechanism adds a small overhead to write operations on the source database while a snapshot exists. For most workloads this is negligible, but on write-heavy OLTP systems with long-lived snapshots, it's worth monitoring.
Drop snapshots when you no longer need them. They're not automatic. Use DROP DATABASE YourSnapshotName to remove them once your change window has closed successfully.
Key Takeaways
- A SQL Server database snapshot captures a read-only, point-in-time copy of a database using a copy-on-write mechanism, storing only changed pages rather than the full database.
- Creating a snapshot takes a single T-SQL statement and executes in seconds, making it ideal as a safety net before high-risk changes.
- Snapshots are not a backup replacement. They depend on the source database being online and intact.
- Snapshot files grow as the source database changes. Monitor disk space and drop snapshots as soon as they're no longer needed.
- Reverting a database to a snapshot requires exclusive access and permanently discards all changes made after the snapshot was taken.
If you're running regular change windows, upgrades, or data migrations and want a consistent process for pre-change snapshots and rollback procedures, DBA Services can help. Our managed support and database health check services include change management practices tailored to your SQL Server environment. Get in touch to find out how we work with Australian organisations to reduce risk around database changes.
Need help with your SQL Servers?
Find out what's really going on inside your SQL Server environment.
Our health checks uncover critical misconfigurations in 97% of reviews.