Attaching a MDF with a missing LDF

  • To attach the mdf file..

    the following ways used bu not use

    1)

    USE [master]

    GO

    EXEC sp_attach_single_file_db @dbname='Lotus',

    @physname=N'G:\folder1\Lotus\Lotus.mdf'

    GO

    error:

    File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Lotus_1.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.

    Msg 1813, Level 16, State 2, Line 1

    Could not open new database 'Lotus'. CREATE DATABASE is aborted.

    2)

    USE master

    GO

    CREATE DATABASE Lotus

    ON PRIMARY

    (FILENAME = N'G:\folder12\Lotus\Lotus.mdf')

    FOR ATTACH_REBUILD_LOG

    GO

    error:

    File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Lotus_1.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.

    Msg 1813, Level 16, State 2, Line 2

    Could not open new database 'Lotus'. CREATE DATABASE is aborted.

    3)

    In Object Explore

    right click on the databases->select attach->addmdf flie

    error:

    TITLE: Microsoft SQL Server Management Studio

    ------------------------------

    Attach database failed for Server 'RAGHAONE-2-PC'. (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1617.0+((KJ_RTM_GDR).110422-1901+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

    ------------------------------

    ADDITIONAL INFORMATION:

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

    ------------------------------

    Could not open new database 'Lotus'. CREATE DATABASE is aborted.

    File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Lotus_1.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)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1617&EvtSrc=MSSQLServer&EvtID=1813&LinkId=20476

    ------------------------------

    BUTTONS:

    OK

    ------------------------------

    plz help me. how to attach the mdf file

  • Restore from backup.

    You've got a data file from a DB that was not shut down cleanly, so SQL cannot just recreate the log file. You can force it to do so, but your database may be transactionally or structurally inconsistent if you do so (and it may not even work)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I tried with Back also... not working.

  • What, the database backup won't restore? (restore from backup as in RESTORE DATABASE <db name> FROM ...)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply