SQL Server DB 2008 wont re-attach after deleting log file

  • I was getting rid of a 150 GB log file using the following process:

    detach the database

    rename the log file

    re-attach the database without the log file

    Everthing was going fine until i realised that i had put the log file on the same drive as the mdf.

    When i tried to do the same thing again, to correct my mistake, it will not re-attach without the log file ?

    Why did it work the first time and not the second time ?

    Thanks

  • what was the attach command you used?

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • I right clicked on databases and attach was one of the options.

  • You can detach, move the log file, re-attach, pick both files from their respective locations.

  • ifila (12/16/2008)


    detach the database

    rename the log file

    re-attach the database without the log file

    Don't do that. Logs are not optional components of the DB and that's a really fast way to stuff a DB up.

    If the log has grown excessively, back it up or switch to simple recovery to empty the log if necessary, then issue a shrink file on the log file.

    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
  • Thanks for the information!

    Sometimes it would delete the log file, other times it would not.

    So i did a restore and and am back to square one.

    I will follow your advice Gail.

Viewing 6 posts - 1 through 5 (of 5 total)

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