SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Replication (2005)
 Rename database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jogin malathi
Posting Yak Master

India
117 Posts

Posted - 06/05/2007 :  03:27:22  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 06/05/2007 :  03:43:41  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
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

India
117 Posts

Posted - 06/05/2007 :  04:46:38  Show Profile  Reply with Quote
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

Edited by - jogin malathi on 06/05/2007 04:47:39
Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 06/05/2007 :  04:57:24  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
"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

India
117 Posts

Posted - 06/05/2007 :  05:54:52  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 06/05/2007 :  06:25:08  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
Are you getting any error?

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

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 06/05/2007 :  09:54:38  Show Profile  Reply with Quote
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 - 08/15/2007 :  16:05:19  Show Profile  Reply with Quote
Right click <RENAME>
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

USA
299 Posts

Posted - 08/15/2007 :  16:23:21  Show Profile  Reply with Quote
alter database db_name
set single_user with rollback immediate

sp_renamedb 'oldname' , 'newname'

Ashley Rhodes
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000