Tutorial - Creating multiple shadow databases at once
Published 23 January 2025
We sometimes get asked how to create a shadow database for the 300 databases I currently have on my dev server. Here's a sample script for SQL Server that may give you ideas to help with this.
- SELECT 'CREATE DATABASE ' + 'z' + name + '_Shadow'
- FROM master.sys.databases
- WHERE name NOT IN
- ('master', 'model', 'msdb', 'tempdb', 'Resource',
- 'distribution' , 'reportserver', 'reportservertempdb')
If there are other databases that are not being actively developed and you don't want a shadow for, then add these names to the NOT IN list.