to create ldf file from an mdf file

  • in a sqlserver database 2005 suppose we dnt have or we lost an ldf file then how to create an ldf file i.e. log file from an existing .mdf file .

  • Use Attach Database method. BTW, You cannot have mdf or ldf files in CE edition. There are actually sdf files.

    --Ramesh


  • Try attach option of the mdf file and it should prompt for creation of new ldf file on verify. Never tried though.

    Thanks

    Prasad Bhogadi
    www.inforaise.com

  • Look for the stored procedure "sp_attach_single_file_db" in SQL Server Books Online (the SQL manual - not actually "online" on the net).

  • You could also use the newer version for attaching database (as sp_attach_single_file_db is deprecated in SQL Server 2005)

    CREATE DATABASE SomeDB

    ON (FILENAME = 'c:\data\SomeDB.mdf')

    FOR ATTACH

    --Ramesh


  • Ooops, an additional quote!!!!

    Edited my previous post:

    --Ramesh


  • megha.chauhan (12/7/2007)


    CREATE DATABASE nwdata (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL\Dataewldf.mdf')FOR ATTACH

    this is the query bt its not executing. can u trace out why?

    thank you

    You missed the ON clause....

    CREATE DATABASE nwdata ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL\Dataewldf.mdf') FOR ATTACH

    --Ramesh


  • I am sounding bit stupid bt that was nt the error I wrote that correctly still it wasn't working it gives the error as

    Device activation error. The physical file name 'C:\Program Files\Microsoft SQL Server\MSSQL\Dataewldf_DATA.mdf' may be incorrect.

    bt file name is correct

  • Do you have the directory path as is given above. Just to test try from Start Menu --> Run --> C:\Program Files\Microsoft SQL Server\MSSQL\

    and see if this folder is accessible. It may sound elementarybut just wondering...

    Thanks

    Prasad Bhogadi
    www.inforaise.com

Viewing 9 posts - 1 through 8 (of 8 total)

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