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’
Here is the list of parameters to pass to PdbswitchDatabase:
|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|