Introduction
Some time, due to log corruption and other reasons, caused the database query. If you separate the database at this point, you will find that you can no longer attach the database, the consequences are very serious. So this article provides a way to make the database query and isolate the instance, still can be attached in a hack way.
Specific Steps
There is currently a database attchsuspectdatabase, with only one table test, where there is only one column of int columns, where data is currently 1, 2. We have questioned this database, as shown in 1.
Figure 1: Database query
At this point, after we detach the database. Attempt to attach, display failed, 2 shown.
Figure 2: The database is no longer attached
Even if we use methods such as rebuilding the log, the discovery still cannot be attached, as shown in 3.
Figure 3: Attempt to rebuild log method append, still invalid
That because the question is the log causes the question, we deleted the log to attach the database directly?
Figure 4: Delete log append, still invalid
At this point, we attach the database by a hack method. First, we create a database with the same name and then thread the database down, and the code looks like this:
ALTER DATABASE [attchsuspectdatabase] SET OFFLINE;
GO
Replace the original database MDF file with the MDF file of the newly created puppet database, at which point the database is attached successfully, but the status is still questioned, as shown in 5.
Figure 5. Hack method attached database succeeded
At this point, we can repair the database by normal means. 6 is shown
At this point, the database with some tips to attach the query is complete.
http://www.cnblogs.com/CareySon/p/3509030.html [Turn]
How to attach a detached query database? Go