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
 Old Forums
 CLOSED - General SQL Server
 Attaching mdf file.

Author  Topic 

aex
Yak Posting Veteran

60 Posts

Posted - 2007-03-27 : 10:40:49
Rarely I need to perform detach/attach stuff during my development. However, I have to develop an application that use sql server user instance (I am not sure I call it right) this recently.

My problem is each time I detach .mdf file from one machine located at, say: D:\Data\Db.mdf. Once after I trasfer this file to other machine at: C:\Db.mdf, then I try to attach this .mdf file. What cause the problem here is sql server doesn't
allow me to attach the file unless I have the .mdf file corresponding .ldf file.

My thought is that sql server should allow me to attach the file and create a .ldf file if it doesn't find one. Any idea why this happen?

Thanks for any reply.

aex

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-27 : 10:57:23
Try using sp_attach_single_file_db.

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

aex
Yak Posting Veteran

60 Posts

Posted - 2007-03-27 : 11:09:04
Thanks harsh for the stored procedures. I will try it out tomorrow to see whether it works. Thanks. :)

aex
Go to Top of Page
   

- Advertisement -