SQL Server 2008 Database attach failure prompt 9004 Error resolution

Source: Internet
Author: User
Tags microsoft sql server mssql mssqlserver

The attach database failed for server "WSS_Content". (MICROSOFT.SQLSERVER.SMO)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
An error occurred while processing the log for database ' WSS_Content '. If possible, restore from a backup. If you do not have a backup available, you may need to regenerate the log.

Unable to open new database ' WSS_Content '. CREATE DATABASE abort. (Microsoft SQL Server, error: 9004)

Cause of the error:

The database file is in an unusual condition, possibly due to a bad drive.

Workaround:

Assume the database name is: wss_content

Follow these steps sequentially:

1, the database file name: Wss_content.mdf renamed to Wss_content_1.mdf;

2, new database: WSS_Content;

3, close the SQL Server service;

4, delete Wss_content.mdb, and renamed WSS_Content_1.mdf to WSS_Content. mdf;

5, start the SQL Server service;

6. Execute the following code:

ALTER DATABASE wss_content set EMERGENCY  Go    ALTER DATABASE wss_content set Single_user with rollback IMMEDIATE
   go use    master  Go    ALTER DATABASE wss_content Rebuild Log on (name = wss_content_log, filename = ' C:\Program F Iles\microsoft SQL server\mssql10_50.mssqlserver\mssql\data\wss_content_log.ldf ')    AlTER database WSS_Content Set Multi_user  


Msg 5025, Level 16, State 1, line 2nd file C:\Program Files\Microsoft SQL Server\mssql10_50.mssqlserver\mssql\data\wss_content_log.ldf ' already exists. You should rename or delete it so that you can create a new log file. Msg 5028, Level 16, State 2, line 2nd The system cannot activate enough databases to rebuild the log.

7. Execute the following code:

ALTER database WSS_Content set Single_user with rollback IMMEDIATE  Go    DBCC CHECKDB (wss_content, Repair_allow_ Data_loss)  DBCC CHECKDB (wss_content, repair_rebuild)    ALTER DATABASE wss_content set Multi_user  

Error messages may be prompted during execution, etc...
8, re-refresh the database, you can!

SQL Server 2008 Database attach failure prompt 9004 Error resolution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.