How to rename SQL Server 2005 database files

Posted on 2007-07-31
Medium Priority
Last Modified: 2012-06-27
I created a database and added data etc. Now I want to rename it. I right clicked and renamed the database in management studio. I was also able to change the logical name. But I'm not able to edit the actual mdf and log file names. I tried to detach the database and then rename the files and that cause the database to not be able to reattach.
Question by:tonyrodriguez
1 Comment
LVL 51

Accepted Solution

Ted Bouskill earned 2000 total points
ID: 19605440
I usually create a new database with the new name.  I then backup the old database, and restore it into the new database and use the overwrite option and changing the 'Restore As' name to the new name (VERY IMPORTANT)

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question