Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

usp_ToggleDatabases

By David Rowland,

usp_ToggleDatabases is a simple procedure that will switch the names of two databases.

One of the main problems with using sp_renamedb to switch databases is that the procedure will wait until the database is free before the rename can be completed. If the new live database is also in use then there is a likelyhood that the renaming of the current database could be successful and the second database will fail.

The procedure attached will wait until all databases are free before trying to switch them around.

A total of 5 sets of databases can be passed to this procedure and it will not start switching any database unless all have noone accessing any of them at a given point.

Total article views: 477 | Views in the last 30 days: 4
 
Related Articles
FORUM

/3GB Switch

/3GB Switch

FORUM

Partition Table Switch Error

Cannot Switch Partition

FORUM

stored procedures in a database

stored procedures in a database

FORUM

Procedure to see database status

Procedure to see database status

FORUM

Problem with ALTER TABLE ... SWITCH

ALTER TABLE .... SWITCH doesnt work

 
Contribute