Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL2000 SQL-server-2005 SQL , +
SQL Server Management Studio is showing me this error:
Msg 5172, Level 16, State 15, Line 1
 
I can't attach this database.Can i extract data from MDF file and how ?
Posted 13-Apr-13 20:56pm
ikaspa388
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Try the procedure described below. It should work unless the damage is really big in which case you’ll need a third party tool such as ApexSQL Recover[^] to actually read the MDF file and restore the data.
 
Stop SQL Server -> Copy database and transaction log files to another location -> Delete original MDF and LDF files -> Start SQL Server again -> Create a new database with same name as the deleted one -> Stop SQL Server again -> overwrite newly created database files with the old one you copied earlier.
 
After this try putting database into EMERGANCY and SINGLE USER mode and execute DBCC CHECKDB command. If you manage to do it up to this place then you should be all good.
 
Important thing is to keep your original MDF and LDF files and work only with copies of these.
  Permalink  
Comments
Christian Graus at 20-Jan-14 23:43pm
   
Wow - the person who 1 voted this has a reasonbly high reputation, my 5 only brought it up to 3. Either way, that's awesome, if that works, I've made a mental note in case I ever need to know this.
arindamrudra at 21-Jan-14 1:35am
   
Awesome trick....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You should try the SQL server recovery software for your recover corrupt SQL database . This software is recovering corrupt database (.mdf file) and effective data recovery services for all users.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

I see this question already asked here and an answer marked as solution too: http://dba.stackexchange.com/questions/39359/how-to-recover-data-from-corrupted-sql-server-database[^]
 
It says:
I’d try the procedure described below or third party tool such as ApexSQL Recover if that doesn’t work and database is severely corrupted.
 
There might be other options out there. This is something that worked for me once but there are no guarantees that it will work at all times.
 
Stop SQL Server instance -> Copy MDF and LDF files to another location -> Delete original MDF and LDF files -> Start SQL Server instance again -> Create new database with exact same name and file names -> Stop SQL Server -> overwrite newly created MDF and LDF.
 
After this your database should be back online. If it is then go ahead and put it into EMERGANCY mode and SINGLE USER mode.
 
Finally go ahead and execute DBCC CHECKDB like this
DBCC CHECKDB (databaseName, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS
If you can get to this and execute last command successfully you should be good. If not then your only options are restoring from backup and/or using 3rd party tools.
  Permalink  
Comments
Sandeep Mewara at 7-Jan-14 11:54am
   
UPDATE: Just noticed this is already answered question. I came to this through a link today that showed no answer. :doh:
SoMad at 8-Jan-14 1:01am
   
Ah, ok. Yes, I have experienced links that lead to a question without answers displayed even though there are answers.
 
Soren Madsen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 495
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 200
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411028.1 | Last Updated 25 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100