Search the Knowledgebase Browse by Category
I have a database marked as suspect or damaged log file (SQL Server 2005 only)
User Opinions
100% thumbs up 0% thumbs down (2 votes)

How would you rate this answer?
Helpful
Not helpful
If you have an mdf file that was not properly detached from SQL Server 2005 (possibly due to a hard drive crash), the first (best!) option is to restore the database from a valid backup.  If that is not an option, then the database is most likely in need of repair.

If the database is in an un-attached state:
  1. Make sure you have a copy of gendata.mdf (or eshadata.mdf)
  2. Run the following SQL Statement in SQL Server Management Studio to attach the database and force SQL Server 2005 to create a new log file:
    CREATE DATABASE gendata ON (NAME = 'gendata', FILENAME = 'c:\Program Files\Esha Research\data\gendata.mdf') FOR ATTACH_REBUILD_LOG;
    Replace the above names with the appropriate names!
Once the database is attached, it is recommended to attempt to backup the database.  If the backup is successful, great (keep going still).  If not, continue on anyway.

The following SQL Statements are meant to address the 'suspect' aspect of the database.
  • ALTER DATABASE gendata SET EMERGENCY
  • ALTER DATABASE gendata SET SINGLE_USER
  • DBCC CHECKDB(gendata, REPAIR_ALLOW_DATA_LOSS)
  • ALTER DATABASE gendata SET MULTI_USER
  • ALTER DATABASE gendata SET ONLINE
You should now have a working database.
Attachments
No attachments were found.
Related Questions
No related questions were found.

Powered by ActiveKB Knowledgebase Software