NDS Care - Customer Support Portal
            Knowledge Base NDS Knowledgebase SQL

            Attach mdf file without ldf file in Database

            SQL SERVER – Unable to Attach Database – File Activation Failure – The Log Cannot be Rebuilt
            Error:


            An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

            Could not open new database 'MyLostDB'. CREATE DATABASE is aborted.
            File activation failure. The physical file name "C:\xxx\MyLostDB.ldf" may be incorrect.
            The log cannot be rebuilt because there were open transactions/users when the database was shutdown, no checkpoint occurred to the database, or the database was read-only. This error could occur if the transaction log file was manually deleted or lost due to a hardware or environment failure. (Microsoft SQL Server, Error: 1813)

            Solution:

            An undocumented option called as ATTACH_FORCE_REBUILD_LOG

            USE master
            GO
            CREATE DATABASE <YOURDBNAME>
            ON (FILENAME = 'D:\<YOURMDFNAME>.mdf')
            FOR ATTACH_FORCE_REBUILD_LOG 
            Updated: 16 Feb 2018 09:16 PM
            Helpful?  
            Help us to make this article better
            0 0