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 2008 Forums
 SQL Server Administration (2008)
 Rename SQL Server 2008 database

Author  Topic 

bob66k88
Starting Member

1 Post

Posted - 2010-01-13 : 17:25:31
How do I rename a database and the associated files?
I know to start by changing database to single-user.
Want to rename testinc database
with related files: testinc.mdf, testinc_1.ndf, testinc_2.ldf
to rkco with related files: rkco.mdf, rkco_1.ndf, rkco_2.ldf

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-13 : 17:46:34
You can use sp_renamedb or ALTER DATABASE to rename the database. To rename the files, detach the database, rename them in Windows Explorer, reattach the database. To rename the logical files, use ALTER DATABASE.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -