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