How to delete ldf ??

  • hi,

    I have a serious issue, i have a replicated server and working as a subscriber, and have log file growing on it and i want to delete or empty my log file for the sake of free disk space.

    please guide me what steps i should follow to delete the log file.

    but keep in mind it is using in replication.

    Thanks and waiting for your guidance.

    ~Noman

  • You should not delete the LDF file.

    BACKUP LOG (your db name) WITH TRUNCATEONLY

    Then run sp_helpdb for your database to get the name of the devices within the database.

    DBCC SHRINKFILE (the database device,size)

  • After backing up your transaction log (providing you have enough space to back it up or even care to back it up)

    You can also do the following to shrink the size of the log file.

    Right click on the database in Management Studio.

    Select Task > Shrink > Files

    Then change the file type drop down to "log".

    Then chose the option "Reorganize pages before releasing unused space".

    Enter 0 in the "Shrink file to" field.

    select "OK" at the bottom

    Note: If your in full recovery mode you'll need to switch to simple.  To do this: Right click on the database, select properties.  Then its on the Options tab on the left.  At the top of this next page you will see "Recovery Model"  This needs to be "Simple" to shrink the log file.  Don't forget to put it back to "Full" when your done.

  • Thanks, it works.

     

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

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