There are a lot of postings on the Internet about repairing databases in Emergency mode. However, only one had the process that worked for me in this case. Most articles just say to run DBCC CHECKDB with the REPAIR_ALLOW_DATA_LOSS option. However, my database was in Read Only mode and wouldn't allow it.
I was also unable to access any database properties through SQL Management Studio. So, I needed to perform most operations by using Transact-SQL when I was attempting to make repairs.
Here is the process that worked for me:
- Take the failed database offline and make a copy of it to use as a backup just in case.
- Stop all SharePoint 2010 services so that they are not attempting to log on to the databases.
- Create a new database named Recovery that uses the same file names in an alternate recovery location
- Take the new database offline
- Copy the old database file to the recovery location and replace the new empty database file.
- Start the Recovery database
- Put the Recovery database into Emergency mode: alter database recovery set emergency
- Put the Recovery database into single user mode: alter database recovery set single_user
- Repair the database with the option to reset/recreate the transaction log file: dbcc checkdb ('recovery',REPAIR_ALLOW_DATA_LOSS)
- Verify that the Recovery database mounted properly and I can view the tables.
- Drop the existing WSS_Content database: drop database wss_content
- Use SQL Management Studio to rename Recovery to WSS_Content.
- Start all SharePoint 2010 services.
- Verify that SharePoint 2010 is functional.