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
 General SQL Server Forums
 New to SQL Server Programming
 ***How do I change a database name?***

Author  Topic 

Paul_Russ
Starting Member

5 Posts

Posted - 2006-12-31 : 11:54:25
Hi,

This is my first posting to this forum. I'm trying to
I'm trying to change the name of my database from ASPNET.mdf to CulturedStar.mdf. I need to change the physical name and logical name.

I'm working with Microsoft SQL Server Management Studio Express.

How do I do this?

Thank you so much for your time and effort ~ Paul

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-31 : 12:01:30
Take a backup of the database, then drop it.
Restore the backup with a new name.,


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Paul_Russ
Starting Member

5 Posts

Posted - 2006-12-31 : 13:44:31
I know how to make a back up but I don't know how to restore it from the .bak file. Can you help? Thanks ~ Paul
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-12-31 : 13:48:41
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=RESTORE%20syntax%20/%20example

Kristen
Go to Top of Page

Paul_Russ
Starting Member

5 Posts

Posted - 2006-12-31 : 15:45:32
Oh yeah, that's specific. I'm trying to restore and it isn't working. Is there a specific script that I can use?

Thanks ~ Paul
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2006-12-31 : 20:41:07
as said in [url=http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76966]this thread[/url], dont backup restore (unless u already dropped db and its too late). use script shown. do u have permissions to perform actions requested? are u getting error messages?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-01 : 04:36:39
"I'm trying to restore and it isn't working"

What error etc. are you getting?

"Is there a specific script that I can use?"

What's the problem with the one I posted?

I now see you've posted a duplicate: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76966

Please don't do that as it causes people to answer your question in multiple places and wastes their time.

Kristen
Go to Top of Page

rajith
Starting Member

2 Posts

Posted - 2007-01-02 : 03:01:36


Hello

Here is the query to change the database name

sp_renamedb 'old_name','new_name'

in urs

sp_renamedb 'aspnet','culturedstar'

it will change to CulturedStar (physically and logically)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-02 : 04:18:32
"physically and logically"

No in SQL 2000 it doesn't. The database name is changed, but not the physical file names, nor the logical names. Which IMO leads to great confusion downstream - either when the MDF/LDF filenames are seen, or attempting to Restore from a Backup using the Logical names as an aide.

Kristen
Go to Top of Page
   

- Advertisement -