dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Invoke-DbaDatabaseClone

Clones a database schema and statistics.

This can be useful for testing query performance without requiring all the space needed for the data in the database.

Read more at sqlperformance.

Thanks to Microsoft Tiger Team for the code and idea.

Screenshots

dbatools-Invoke-DbaDatabaseClone

Examples

Clones mydb to myclone on sql2016.

Invoke-DbaDatabaseClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone

Updates the statistics of mydb then clones to myclone and myclone2.

Invoke-DbaDatabaseClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone, myclone2 -UpdateStatistics

Author

This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.

Get-Help

From PowerShell, execute Get-Help Invoke-DbaDatabaseClone -Detailed for more information on this function.

Source Code

Want to see the source code? View Invoke-DbaDatabaseClone.ps1 on GitHub
 

Related commands