Friday, February 10, 2012

Attach a database without log file (ldf fife)

I downloaded SQL Server 2012 RC0 today and the sample database to poke around from here. The download contains the data file (mdf file) of adventure works but not ldf. For a moment, I thought why would codeplex not include ldf file - it seems that it is indeed possible to attach a database without ldf file.

Head over to CREATE Database on BOL and CTRL+F for  " FOR_ATTACH_REBUILD_LOG"
Script below:

2 comments:

  1. Hello Kuppala,

    You can also attach your database by below method.

    CREATE DATABASE AdventureWorks2008R2 ON

    ( FILENAME ='C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008R2_Data.mdf')

    FOR ATTACH
    GO

    Regards,
    Mark Willium
    Blog

    ReplyDelete