Have Only MDF, no LDF

  • I was at a friends office, and was going to get the MDF and LDF files on a database that I need to work with.  The systems administrator didn't have any "shrink" plan in place, so the LDF file was massive.  I didn't want to shrink it myself, because I'm not an administrator, so I just took the MDF.

    Lets call this DataOne.MDF.  I created a database DataOne, then stopped SQL Server, copied the original DataOne over the newly created file.  Since I didn't have the LDF, SQL Server didn't like this.  I tried deleting the LDF, hoping SQL would create a good one, but that didn't happen.

    Any suggestions?  I'd have these guys send me the shrunk MDF and LDF, but they are totally disorganized.  If there is a way to do this, I'd rather not deal with the administrator there, LOL. 

    Maybe the answer is, "What do you do if you have a good MDF, but corrupt LDF file?"

  • I would try attaching the mdf, sometimes this will create the ldf for you.  Also see this thread:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=9&messageid=153901

     

    Aunt Kathi Data Platform MVP
    Author of Expert T-SQL Window Functions
    Simple-Talk Editor

  • Try using sp_attach_single_file_db. Below is the syntax.

    sp_attach_single_file_db [ @dbname = ] 'dbname'

        , [ @physname = ] 'physical_name'

  • Thank you, worked well

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

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