none
error 9003 when attaching a database

    Question

  • i had a database that was marked SUSPECT and on the process of resolving the issue i took the db offline the detach and when am trying to attach again am geting the erro 9003

    Kindly assist

    Wednesday, March 6, 2013 7:52 AM

Answers

  • Hello,

    Do you mean this error:
    The log scan number %S_LSN passed to log scan in database '%.*ls' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.

    As the message already says, one option is to restore the database from the last valid backup.

    Other options is:
    - Detach the database
    - Rename/Move the log file
    - Attach the MDF database file without the LOG file; a new log will be created.


    Olaf Helper

    Blog Xing


    Wednesday, March 6, 2013 8:20 AM
    Moderator

All replies

  • Do you have a last good backup  of that db?

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Blog: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance

    Wednesday, March 6, 2013 8:18 AM
    Moderator
  • Hello,

    Do you mean this error:
    The log scan number %S_LSN passed to log scan in database '%.*ls' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.

    As the message already says, one option is to restore the database from the last valid backup.

    Other options is:
    - Detach the database
    - Rename/Move the log file
    - Attach the MDF database file without the LOG file; a new log will be created.


    Olaf Helper

    Blog Xing


    Wednesday, March 6, 2013 8:20 AM
    Moderator
  • Was the database cleanly shutdown? If Yes then try to attach database without ldf file, ldf file will be automatically created for the database.

    Bellow steps help in case of database was not cleanly shutdown.

    • Create a same size database
    • Now shutdown the SQL server
    • Change the old mdf file with new one
    • Start the SQL server, your database may go in suspect mode
    • Now change your database status from suspect mode to emergency mode by ALTER Database command
    • Run DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS. It will rebuild the log and run full repair

    Note: You may loss some amount of database by performing above steps. Try it as a last resort. 

    Wednesday, March 13, 2013 3:23 AM