Redgate Flyway

For PostgreSQL users - where are your DBs hosted?

Tutorial - Creating multiple shadow databases at once

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.

  1. SELECT 'CREATE DATABASE ' + 'z' + name + '_Shadow'
  2. FROM master.sys.databases
  3. WHERE name NOT IN
  4. ('master', 'model', 'msdb', 'tempdb', 'Resource',
  5. '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.


Didn't find what you were looking for?