December 2015
Intermediate to advanced
760 pages
14h 31m
English
In this recipe, we will look at how to copy a database using PowerShell and SMO.
In this recipe, we will create a copy of the database TestDB and call it TestDB_Copy. We will assume you have the TestDB database already created from previous recipes. If you do not have it, you can also substitute this with any database you already have in your instance.
Let's list the steps required to copy a database using PowerShell.
#import SQL Server module Import-Module SQLPS -DisableNameChecking #replace this with your instance name $instanceName = "localhost" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server ...
Read now
Unlock full access