ERROR : 9004 An error occurred while processing the log for database.

I was trying to attach a database which was in other server to my server. When doing it so I got the below error which was unusual. So I did some experiments to resolve it.

ERROR : 9004 An error occurred while processing the log for database.
If possible, restore from backup.
If a backup is not available, it might be necessary to rebuild the log.

To rectify the issue. you have to follow some steps.

1) Create a new database with same name and .mdf and .ldf files as well.
2) Stop all services of SQL server in the instance where you are trying to attach i.e. instance where you created new database
3) Replace the mdf and ldf files on to the existing one which was created newly.
4) Start the services of SQL Server.
5) Database will be in suspect mode i.e. it will show DatabaseName (Recovery Pending) as shown below. You can access tables of this database at this mode.

6) Run below command to put your database from suspect mode to emergency mode. Running this command will turn your database in to pinkish in color.

ALTER DATABASE <DatabaseName> SET EMERGENCY

7) Now you can access tables of this database.

For more reference check this link
http://blog.sqlauthority.com/2008/07/21/sql-server-fix-error-9004-an-error-occurred-while-processing-the-log-for-database-if-possible-restore-from-backup-if-a-backup-is-not-available-it-might-be-necessary-to-rebuild-the-log/

3 comments:

  1. MS SQL is a well known relational database management system. Moreover,you can store and manage huge amount of data and can also modify it. It makes use of Transaction log which is integral module of SQL Server instance. In spite of being so popular errors frustrate users. One such error is SQL Error 9004 which needs to be resolved immediately.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. The space bar, also called the 'spacebar' or 'space key', is one of the most commonly used keys on a computer keyboard. It is used to place space in something that is being typed. It's at the bottom of most standard keyboard layouts, like the QWERTY keyboard. The space bar is wider than all the other keys on the keyboard.
    Space bar test

    ReplyDelete