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 2000 Forums
 SQL Server Development (2000)
 Restoring a .MDF file

Author  Topic 

pug2694328
Posting Yak Master

166 Posts

Posted - 2007-01-04 : 17:26:31
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: http://forums.belution.com/en/sql/000/017/79s.shtml

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

, 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 - 2007-01-04 : 17:34:11
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.



CODO ERGO SUM
Go to Top of Page

pug2694328
Posting Yak Master

166 Posts

Posted - 2007-01-04 : 18:12:33
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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-04 : 19:37:36
Why do you think you don't need the .ndf file?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-05 : 01:02:31
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: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=single%20file%20attach,sp_attach_single_file_db

Kristen
Go to Top of Page

babaweso
Starting Member

1 Post

Posted - 2012-08-14 : 10:34:13
Just please delete the LDF file thwn normally attach it , it will creat a new onw automaticlly
Go to Top of Page
   

- Advertisement -