in SQL 2008,only MDF,NDF,no Ldf,how to attach

  • hi guys,

    one of our database 's log file is very big,then i attach the database,and delete log file,

    now i only have mdf and ndf file,when i want to attach it, it show error.

    it is in SQL 2008 system.

  • What error?

    If it's complaining about the DB not been shut down cleanly then you should restore your latest backup.

    If you don't have a backup (and why not), have a look at this blog post.

    http://sqlinthewild.co.za/index.php/2009/06/09/deleting-the-transaction-log/

    Going forward, ensure that your log backups are running properly and don't ever delete a transaction log.

    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
  • :w00t:

    Never!, never!, delete a Log File!

    http://www.sqlservercentral.com/articles/Disaster+Recovery/63311/

  • totally agree, NEVER delete a LDF file.

    But in your case i would try the following statement:

    CREATE DATABASE [dbname] ON

    (NAME = Name, FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\db.mdf')

    FOR ATTACH_REBUILD_LOG;

    /mSc

    http://www.performanceduo.com

  • msc (8/8/2009)


    CREATE DATABASE [dbname] ON

    (NAME = Name, FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\db.mdf')

    FOR ATTACH_REBUILD_LOG;

    That only works if the database has been shut down cleanly. If it has not, any attempt to attach throws an error.

    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 5 posts - 1 through 4 (of 4 total)

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