There may be different cases in which you wish to switch between databases, based on the company’s needs.

One of the common cases to switch between databases is when upgrading a database version. Once the new database is upgraded and ready to go, it is switched with the old database and becomes the active one (refer to our post how to track changes in your database for an example). Switching makes the transition smooth, fast and transparent.

Switching databases is not a complicated task; however, it requires following all these steps:

  • Turn off databases
  • Rename database names in SQL Server Instance
  • Change databases files names; Log and all MDF files that are associated with the databases
  • Turn back on the databases service

The PartiontDB switch Add-in performs all this work for you within one command:

Exec PdbLogic..PdbswitchDatabase @SourceDatabaseName=’oldDB’, @TargetDatabaseName=’newDB’

Just pass the names of the two databases, and you are all set. The names will be switched, as well as the associated file names, the log file and MDF file.

Note that in order to use this Add-in, you need to download our PdbLogic.

Here is the list of parameters to pass to PdbswitchDatabase:

Parameter Description Mandatory
SourceDatabaseName Name of source database Yes
IsOutputScript Decide if to print the command or run it No
LinkedServerName Name of linked server (same for source and target) No
TargetDatabaseName Name of target database Yes
SwitchSuffix Suffix for temporary database name for the switch Yes

To use switch Add-in and other PartitionDB Add-ins, download our PdbLogic and attach to your database. .
To learn more about PartitionDB capabilities check out our blog.