Error on renaming database in SQL Server 2008 R2

Error on renaming database in SQL Server 2008 R2



use master

ALTER DATABASE OldDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE    
ALTER DATABASE OldDatabaseName MODIFY NAME = [New_DatabaseName]

ALTER DATABASE New_DatabaseName SET MULTI_USER



Notes: you should use WITH ROLLBACK IMMEDIATE while altering a database that other users might be operating on, in order to ensure the integrity of these operations. But it is not really necessary when setting the database back to MULTI_USER mode again since the database is already at SINGLE_USER mode and you are the only user able to run any transactions anyway.


















Comments

Popular posts from this blog

how to fetch all HTML Table Records and modify all records accordingly using jquery and Javascript

Optimize Process Speed using C#

how to Replace null value with 0 Using C#