Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Development
 How to: Create a Database Snapshot ...
Community Content
In this section
Statistics Annotations (3)
Collapse All/Expand All Collapse All
Other versions are also available for the following:
SQL Server 2008 Books Online (October 2009)
How to: Create a Database Snapshot (Transact-SQL)

The only way to create a database snapshot is to use Transact-SQL. Any user who can create a database can create a database snapshot; however, to create a snapshot of a mirror database, you must be a member of the sysadmin fixed server role.

ms175876.note(en-us,SQL.100).gifNote:
For considerations on naming database snapshots, timing their creation, and limiting their number, see Creating a Database Snapshot.

  1. Ensure that you have sufficient disk space to hold the database snapshot. The maximum size of a database snapshot is the size of the source database at snapshot creation.

  2. Issue a CREATE DATABASE statement on the files using the AS SNAPSHOT OF clause. Creating a snapshot requires specifying the logical name of every database file of the source database. For a formal description of the syntax for creating a database snapshot, see CREATE DATABASE (Transact-SQL).

    ms175876.note(en-us,SQL.100).gifNote:
    When you create a database snapshot, log files, offline files, restoring files, and defunct files are not allowed in the CREATE DATABASE statement.

This section contains examples of creating a database snapshot.

A. Creating a snapshot on the AdventureWorks database

This example creates a database snapshot on the AdventureWorks database. The snapshot name, AdventureWorks_dbss_1800, and the file name of its sparse file, AdventureWorks_data_1800.ss, indicate the creation time, 6 P.M (1800 hours).

CREATE DATABASE AdventureWorks_dbss1800 ON
( NAME = AdventureWorks_Data, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\AdventureWorks_data_1800.ss' )
AS SNAPSHOT OF AdventureWorks;
GO
ms175876.note(en-us,SQL.100).gifNote:
The .ss extension used in the examples is arbitrary.

B. Creating a snapshot on the Sales database

This example creates a database snapshot, sales_snapshot1200, on the Sales database. This database was created in the example, "Creating a database that has filegroups," in CREATE DATABASE (Transact-SQL).

--Creating sales_snapshot1200 as snapshot of the
--Sales database:
CREATE DATABASE sales_snapshot1200 ON
( NAME = SPri1_dat, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\data\SPri1dat_1200.ss'),
( NAME = SPri2_dat, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\data\SPri2dt_1200.ss'),
( NAME = SGrp1Fi1_dat, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\mssql\data\SG1Fi1dt_1200.ss'),
( NAME = SGrp1Fi2_dat, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\data\SG1Fi2dt_1200.ss'),
( NAME = SGrp2Fi1_dat, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\data\SG2Fi1dt_1200.ss'),
( NAME = SGrp2Fi2_dat, FILENAME = 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\data\SG2Fi2dt_1200.ss')
AS SNAPSHOT OF Sales
GO
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Only System administrators can create a snapshot of non-recovered mirrored database.      Ramu_K ... Chandan_SQLDBA   |   Edit   |   Show History
Please note that only a user that is a member of sysadmin fixed server role, can create a snapshot of the non-recovered mirror database on the mirror server.


Ramu Konidena
Microsoft SQL Server Support.



Databse Snapshot Features is available only in SQL Enterprise Edition not in Standard Edition

Chandan Gupta
SQL_DBA
IBM Technologies
Flag as ContentBug
Only available for Enterprise Edition      Uwe Ricken   |   Edit   |   Show History
Please note that creation of snapshots will only be available in the Enterprise Edition of SQL Server 2005 / 2008.

Uwe Ricken
SQL DBA
db Berater GmbH (Germany)
Tags What's this?: Add a tag
Flag as ContentBug
Luan.Moreno      Luan.Moreno ... Thomas Lee   |   Edit   |   Show History
This article solve all my problems

Congratulations
It's so good to participate the TECH NET

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker