Showing posts with label sp_renamedb. Show all posts
Showing posts with label sp_renamedb. Show all posts

Friday, March 30, 2012

Renaming a subscriber

Are there any "gotchas" to renaming a database (sp_renamedb) that is a subscriber to merge replication. I can't seem to find much info on this on google.
Yes. The merge agent will fail because it cannot find the original database.
Rand
This posting is provided "as is" with no warranties and confers no rights.

Friday, March 23, 2012

rename database but error for exclusive lock

Hello,
I want to rename a database and i am using sp_renamedb
'olddatabasename', 'newdatabasename' but i receive errors.
database could not be exclusively locked to perform the operation
what is that i can do about that?
*** Sent via Developersdex http://www.developersdex.com ***Hi,
While renaming, No users should be connected to the database. You can turn
on the database to single user mode by executing the below command.
ALTER DATABASE <DBNAME> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
SP_RENAMEDB <oldname>,<Newname>
Go
ALTER DATABASE <NEWDBNAME> SET MULTI_USER -- set back to multi user
GO
Thanks
Hari
SQL Server MVP
"ilias Mintidis" <imintidi@.sebh.org> wrote in message
news:%23x1mmfeOFHA.1396@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I want to rename a database and i am using sp_renamedb
> 'olddatabasename', 'newdatabasename' but i receive errors.
> database could not be exclusively locked to perform the operation
> what is that i can do about that?
>
> *** Sent via Developersdex http://www.developersdex.com ***|||Hi Illias,
No need to select the database name. From master you can execute the ALTER
DATABASE statement to set the database to single user mode.
Thanks
Hari
SQL Server MVP
"ilias Mintidis" wrote:
> great ,thanks ,one more question in this.
> The server has also another database loaded,which isc the LIVE
> database.i am doing the rename of a test database,so i can restore an
> additional database from .bak file.
> do i have to specify which database i put in single user mode?Do i do
> that by selecting the test database from the drop down in sql analyser?
>
> *** Sent via Developersdex http://www.developersdex.com ***
>sql

rename database but error for exclusive lock

Hello,
I want to rename a database and i am using sp_renamedb
'olddatabasename', 'newdatabasename' but i receive errors.
database could not be exclusively locked to perform the operation
what is that i can do about that?
*** Sent via Developersdex http://www.codecomments.com ***Hi,
While renaming, No users should be connected to the database. You can turn
on the database to single user mode by executing the below command.
ALTER DATABASE <DBNAME> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
SP_RENAMEDB <oldname>,<Newname>
Go
ALTER DATABASE <NEWDBNAME> SET MULTI_USER -- set back to multi user
GO
Thanks
Hari
SQL Server MVP
"ilias Mintidis" <imintidi@.sebh.org> wrote in message
news:%23x1mmfeOFHA.1396@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I want to rename a database and i am using sp_renamedb
> 'olddatabasename', 'newdatabasename' but i receive errors.
> database could not be exclusively locked to perform the operation
> what is that i can do about that?
>
> *** Sent via Developersdex http://www.codecomments.com ***|||great ,thanks ,one more question in this.
The server has also another database loaded,which isc the LIVE
database.i am doing the rename of a test database,so i can restore an
additional database from .bak file.
do i have to specify which database i put in single user mode?Do i do
that by selecting the test database from the drop down in sql analyser?
*** Sent via Developersdex http://www.codecomments.com ***|||Hi Illias,
No need to select the database name. From master you can execute the ALTER
DATABASE statement to set the database to single user mode.
Thanks
Hari
SQL Server MVP
"ilias Mintidis" wrote:

> great ,thanks ,one more question in this.
> The server has also another database loaded,which isc the LIVE
> database.i am doing the rename of a test database,so i can restore an
> additional database from .bak file.
> do i have to specify which database i put in single user mode?Do i do
> that by selecting the test database from the drop down in sql analyser?
>
> *** Sent via Developersdex http://www.codecomments.com ***
>