Error 5030 Sql Server
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have can't rename database sql server Meta Discuss the workings and policies of this site About Us unable to rename sql server database Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with rename failed for database exclusively locked us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just unable to rename database exclusively locked like you, helping each other. Join them; it only takes a minute: Sign up Error on renaming database in SQL Server 2008 R2 up vote 68 down vote favorite 19 I am using this query to rename the database: ALTER DATABASE BOSEVIKRAM MODIFY NAME = [BOSEVIKRAM_Deleted] But it shows an error when excuting: Msg 5030, Level 16,
Sql Server Error 952
State 2, Line 1 The database could not be exclusively locked to perform the operation. Is anything wrong with my query? sql sql-server sql-server-2008-r2 share|improve this question edited May 22 '13 at 8:09 marc_s 452k938641029 asked May 22 '13 at 6:53 Vikram Bose 1,0461619 4 There's nothing wrong with the query - the error is telling you that other connections are connected to the database, so you're not allowed to rename it at this time. –Damien_The_Unbeliever May 22 '13 at 6:55 1 If you're doing this from SSMS, make sure you don't have a query window open against that db, as that's a separate connection that places a lock on the db. –jdl134679 Feb 19 at 9:17 add a comment| 7 Answers 7 active oldest votes up vote 145 down vote accepted You could try setting the database to single user mode. http://stackoverflow.com/a/11624/2408095 use master ALTER DATABASE BOSEVIKRAM SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE BOSEVIKRAM MODIFY NAME = [BOSEVIKRAM_Deleted] ALTER DATABASE BOSEVIKRAM_Deleted SET MU
(Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsTroubleshootingCommunityForums Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My
Sqlserver 5030
Forums Answered by: Error: the database could not be microsoft sql server error 5030 collation exclusively locked to perform the operation in sql server 2008 ? SQL Server > Transact-SQL error 5030 sql server 2012 Question 0 Sign in to vote I am trying to rename the database but i am getting below exception while doing it--> Error: http://stackoverflow.com/questions/16685269/error-on-renaming-database-in-sql-server-2008-r2 the database could not be exclusively locked to perform the operation.(Microsoft Sql Server,Error 5030) Thanks. Tuesday, October 23, 2012 9:08 AM Reply | Quote Answers 1 Sign in to vote Thats because someone else is accessing the database.. Put the database into single user mode the rename it. https://social.msdn.microsoft.com/Forums/sqlserver/en-US/73311770-92a1-4ff8-b29b-0462f6053a17/error-the-database-could-not-be-exclusively-locked-to-perform-the-operation-in-sql-server-2008-?forum=transactsql USE [master]; GO ALTER DATABASE foo SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO EXEC sp_renamedb N'foo', N'bar'; vtPlease mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker Proposed as answer by Andrew Bainbridge Tuesday, October 23, 2012 9:15 AM Marked as answer by Maggy111 Tuesday, October 23, 2012 9:22 AM Tuesday, October 23, 2012 9:11 AM Reply | Quote All replies 1 Sign in to vote Thats because someone else is accessing the database.. Put the database into single user mode the rename it. USE [master]; GO ALTER DATABASE foo SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO EXEC sp_renamedb N'foo', N'bar'; vtPlease mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker Proposed as answer by Andrew Bainbridge Tuesday, October 23,
sp_renamedb, t-sql -- Michael J. Swart @ 3:41 pm If you've ever used Object Explorer (in SSMS) in order to rename http://michaeljswart.com/tag/error-5030/ a database, you may have come across this error message from Management Studio: which says: Unable to rename [database]. (ObjectExplorer) Additional information: --> Rename failed for Databse '[databse]'. (Microsoft.SqlServer.Smo) --> An exception occured while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) --> The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, sql server Error: 5030) Management Studio is telling you that there are connections that it doesn't want to mess with. Or when using sp_renamedb from a query window, you might see this similar error: Msg 5030, Level 16, State 2, Line 1 The database could not be exclusively locked to perform the operation. If you really really error 5030 sql want to rename the database and don't care at all about in-flight transactions, then use this script/template I recently came up with: A Forceful Script: ALTER DATABASE [old_name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE [old_name] MODIFY NAME = [new_name] GO ALTER DATABASE [new_name] SET MULTI_USER GO Caveat: Remember that this script failed kindegarten for not playing well with others. So use this script only on QA and Dev boxes. And if you're going to do something on a production box, make sure you do this only during scheduled downtime. One More Interesting Thing: A friend of mine stored this script in One Note and found that when it came to use it, the script failed because One Note had replaced some of the white space with non breaking spaces! This issue is a One Note issue and applies to all scripts and code, not just T-SQL scripts. -- Comments (6) Subscribe by email: Search for: Browse by Illustration: Powered by WordPress