Creating a database snapshot
In this recipe, we will create a database snapshot.
Getting ready
SQL Server database snapshots require either the SQL Server Developer or Enterprise edition. You can also use the Evaluation edition, which is similar to the Enterprise edition.
We will use the script called B04525 - Ch06 - 04 - Creating a Database Snapshot - Prep.ps1 to create a sample database that we will base our snapshot on. The database created in this script will have multiple Filegroups and data files.
Alternatively, you can choose a source database that you would like to serve as the base of your snapshot.
How to do it...
Let's take a look at the steps to create a database snapshot:
- Open PowerShell ISE as an administrator.
- Import the
SQLPS
module and create a new SMO Server object as follows:#import SQL Server module Import-Module SQLPS -DisableNameChecking $instanceName = "localhost" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName...