Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Restoring a .MDF file
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

166 Posts

Posted - 01/04/2007 :  17:26:31  Show Profile  Reply with Quote
We have a third party that sends us a cd containing one MDF and one NDF file.

I'd like to 'restore' these to our server as a database. I don't have the LDF file and will never get it. I'm not sure that I need the NDF file.

Per this string:

I should be able to create a db on my server with a duplicate name

, then detach it,
EXEC sp_detach_db 'A006CBCB', 'true'

overwrite the MDF file for my empty DB with the one from the cd,

then reattach the db.
EXEC sp_attach_db @dbname = N'A006CBCB',
@filename1 = N'D:\SQL\DATA\MSSQL\Data\A006CBCB.mdf',
@filename2 = N'D:\SQL\DATA\MSSQL\Data\A006CBCB_log.LDF'

Where I hit the following errors:

Server: Msg 5173, Level 16, State 2, Line 1
Cannot associate files with different databases.

Any thoughts?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 01/04/2007 :  17:34:11  Show Profile  Reply with Quote
It sound like you are dealing with a "third party" who has no idea what they are doing.

Ask them to send you a SQL Server database backup file.

Go to Top of Page

Posting Yak Master

166 Posts

Posted - 01/04/2007 :  18:12:33  Show Profile  Reply with Quote
Yup, that would be ideal, but sadly not going to happen.

The disk is some proprietary stuff they send our clients and expect them to run their install scripts that load the data for some skimpy custom GUI they offer. We're tasked with pulling the underlying data so the data analysis can be automated rather than accessed manually.

So if anyone has some thoughts on restoring the data from just a .mdf, please do tell.
Go to Top of Page

Patron Saint of Lost Yaks

30421 Posts

Posted - 01/04/2007 :  19:37:36  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Why do you think you don't need the .ndf file?

Peter Larsson
Helsingborg, Sweden
Go to Top of Page


United Kingdom
22859 Posts

Posted - 01/05/2007 :  01:02:31  Show Profile  Reply with Quote
Don't you need to use the Single File Attach method if you don't have an LDF file? I'm a bit sketchy on whether that supports NDF files ...

See also:,sp_attach_single_file_db

Go to Top of Page

Starting Member

Saudi Arabia
1 Posts

Posted - 08/14/2012 :  10:34:13  Show Profile  Reply with Quote
Just please delete the LDF file thwn normally attach it , it will creat a new onw automaticlly
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000