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
 One or more files do not match the primary file of

Author  Topic 

jooorj
Posting Yak Master

126 Posts

Posted - 2011-09-25 : 08:01:40
Please tell me how to resolve this problem.

I had tiered
I can not attach Database from MDF file.
what should I do ?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-25 : 08:04:35
why? whats the error message you got when you tried to connect? do you have all the files that make up the db?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jooorj
Posting Yak Master

126 Posts

Posted - 2011-09-25 : 08:13:43
Msg 5173, Level 16, State 1, Line 6
One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.
Log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mail_log.ldf' does not match the primary file. It may be from a different database or the log may have been rebuilt previously.
Msg 1813, Level 16, State 2, Line 6
Could not open new database 'Mail'. CREATE DATABASE is aborted.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-25 : 08:20:04
can you post your attach command? or are you using wizard?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

vmvadivel
Yak Posting Veteran

69 Posts

Posted - 2011-09-25 : 08:59:27
Is it like you have only the MDF and not the LDF file? i.e., Are you trying to attach a MDF file without corresponding LDF file? If so then try out the steps explained in this thread - http://stackoverflow.com/questions/773059/how-to-recover-database-from-mdf-in-sql-server-2005

Best Regards
Vadivel

http://vadivel.blogspot.com
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-09-25 : 13:00:25
You're mixing files from multiple databases. Specifically the ldf file that you are trying to use does not belong to that database. Find the correct files and attach those.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-25 : 13:02:19
also see

http://www.sqlskills.com/blogs/paul/post/TechEd-Demo-Creating-detaching-re-attaching-and-fixing-a-suspect-database.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-09-25 : 13:02:28
quote:
Originally posted by vmvadivel

If so then try out the steps explained in this thread - http://stackoverflow.com/questions/773059/how-to-recover-database-from-mdf-in-sql-server-2005


A lot of the advice on that thread is extremely dangerous.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -