View Thread
 Print Thread
Rename database
admin
Ever tried renaming a database only to find yourself with the error:

Quote

MSSMS Error:
The database could not be exclusively locked to perform the operation


The simple work around is to disconnect users as you do it:

Quote

ALTER DATABASE db_Before SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE db_Before MODIFY NAME = db_After
ALTER DATABASE db_After SET MULTI_USER WITH ROLLBACK IMMEDIATE


Why MSSMS does not do this is beyond me.... (or at least prompt with the option to disconnect users)
Jordon Pilling | Heavencore Administrator
 
Jump to Forum