locked
Fail to attach a database RRS feed

  • Question

  • Hi all, I am using a sql server 2008 to attach .mdf and .ldf files. When I try to attach webforms17, the following message appears. As I am new with SQL Server 2008, can someone please show me a step by step approach to fix this error? I tried to look for solutions over the internet for two days and found no result :(. Not sure about the cause of this error. Thanks. __________________________________________________________________________________________________________________TITLE: Microsoft SQL Server Management Studio ------------------------------ Attach database failed for Server 'JAY-PC\jay'. (Microsoft.SqlServer.Smo) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1+((KJ_RTM).100402-1539+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476 ------------------------------ ADDITIONAL INFORMATION: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) ------------------------------ SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:909; actual 0:0). It occurred during a read of page (1:909) in database ID 7 at offset 0x0000000071a000 in file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.JAY\MSSQL\DATA\Webforms-17.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. Could not open new database 'webform17'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 824) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=824&LinkId=20476 ------------------------------ BUTTONS: OK ------------------------------
    • Edited by JayNoob Tuesday, December 13, 2011 9:40 AM
    Tuesday, December 13, 2011 9:38 AM

Answers

  • No, I don'thave any data backup :(

    Did you say in the previous thread that you had a backup from Dec 4th, but you needed to get the data from the 5th?

    Try this:

    1) Create a new database, call it LastChance.
    2) ALTER DATABASE LastChance SET EMERGENCY
    3) Stop SQL Server.
    4) Throw the data files for LastChance away.
    5) COPY - don't rename! - the files for your broken database to the name   of the files for the LastChance database.
    6) Start SQL Server.
    7) Check the SQL Server errorlog whether it liked the database. (You find the SQL Server errorlog in the LOG directory for your instance.)
    8) If the database became available, run DBCC CHECKDB(LastChance) post the output here.

    There is no guarantee that this will work. If it fails, you have probably exhausted the possibilities to access the database with help of SQL Server.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Marked as answer by amber zhang Tuesday, December 20, 2011 1:28 AM
    Tuesday, December 13, 2011 10:41 PM

All replies

  • Looks like the data file is corrupted.. I hope that you do have a last good FULL backup of the database otherwise I am afraid you are out of luck
    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    Tuesday, December 13, 2011 10:02 AM
  • No, I don'thave any data backup :(
    Tuesday, December 13, 2011 7:02 PM
  • did you try to attach it with out .ldf file?
    fk
    Tuesday, December 13, 2011 7:23 PM
  • No, I don'thave any data backup :(

    Did you say in the previous thread that you had a backup from Dec 4th, but you needed to get the data from the 5th?

    Try this:

    1) Create a new database, call it LastChance.
    2) ALTER DATABASE LastChance SET EMERGENCY
    3) Stop SQL Server.
    4) Throw the data files for LastChance away.
    5) COPY - don't rename! - the files for your broken database to the name   of the files for the LastChance database.
    6) Start SQL Server.
    7) Check the SQL Server errorlog whether it liked the database. (You find the SQL Server errorlog in the LOG directory for your instance.)
    8) If the database became available, run DBCC CHECKDB(LastChance) post the output here.

    There is no guarantee that this will work. If it fails, you have probably exhausted the possibilities to access the database with help of SQL Server.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Marked as answer by amber zhang Tuesday, December 20, 2011 1:28 AM
    Tuesday, December 13, 2011 10:41 PM
  • Yeah,

     

    I tried every possible solutions on the net but still no avail. I guess that data is corrupted pretty badly. However, Thanks for your help Erland. the information that you provided is good for future reference.

    Thursday, December 15, 2011 6:19 AM