Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Replication (2005)
 Rename database

Author  Topic 

jogin malathi
Posting Yak Master

117 Posts

Posted - 2007-06-05 : 03:27:22
hi
How can i rename database name through command
Here i tried with the folloeing statement

ALTER DATABASE indraja1
MODIFY NAME = indraja11

but i got error as


Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.


Thanks in Advance

Malathi Rao

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-05 : 03:43:41
Before renaming database, you need to set it to single-user mode. Have you done that?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jogin malathi
Posting Yak Master

117 Posts

Posted - 2007-06-05 : 04:46:38
quote:
Originally posted by harsh_athalye

Before renaming database, you need to set it to single-user mode. Have you done that?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"


no iam trying to take database ofline
and how to set database to single-user mode
Malathi Rao
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-05 : 04:57:24
"how to set database to single-user mode"

Use Master
GO

Alter database <db-name>
Set Single_User
GO


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jogin malathi
Posting Yak Master

117 Posts

Posted - 2007-06-05 : 05:54:52
quote:
Originally posted by harsh_athalye

"how to set database to single-user mode"

Use Master
GO

Alter database <db-name>
Set Single_User
GO


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"




i tried with the above statement
but its not executing
can u show me some exapmle


Malathi Rao
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-05 : 06:25:08
Are you getting any error?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-06-05 : 09:54:38
Add 'ROLLBACK IMMEDIATE' in 'alter database' statement if users are connecting to the db.
Go to Top of Page

homebrew
Posting Yak Master

114 Posts

Posted - 2007-08-15 : 16:05:19
Right click <RENAME>
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

299 Posts

Posted - 2007-08-15 : 16:23:21
alter database db_name
set single_user with rollback immediate

sp_renamedb 'oldname' , 'newname'

Ashley Rhodes
Go to Top of Page
   

- Advertisement -