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
 copy .mdf and attach as new db

Author  Topic 

smorty44
Yak Posting Veteran

93 Posts

Posted - 2008-05-02 : 12:51:42
I have copied the .mdf and .ldf files from one db and I'd like to attach the copies to a new db on the same server. When I try to attach the copied files I get the error, "the physical file name may be incorrect". Original db filename is "MC_DISC_Data.mdf", I copied this and renamed it to, "MC_Data.mdf" in my sqldata folder. I can see the physical file name is still the original name when I'm trying to attach db using EM, how can I change it to the copied name?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-02 : 14:06:35
When you did the copy, was the SQL Server serice stopped? If not, then your files are no good.

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

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-05-03 : 20:46:02
Don't think it'll work since system table in the db still has old file name. You need attach with whatever name the file has, backup the db, create new db with new name, then restore with move option.
Go to Top of Page
   

- Advertisement -