SQL- Server – Free disk SPACE USING SHRINK

 Understanding shrinking the log

If you need to recover disk space from the transaction log file, consider shrinking the log file.

Shrinking logs helps after you perform an action that creates a large number of logs.

You can only shrink the log if there is free space on the log file.

Shrink the transaction log

Use the following steps to truncate the transaction log file:

  • 1. Right-click the database and select Tasks -> Shrink -> Files.


  • 2. Change the type to Log.
  • 3. Under Shrink action, select Release unused space and click OK.


What if the log size does not decrease?

If the size of the log does not change much after this, it means that your database has the recovery mode set to Full and there is not enough unused space to recover.


At this point you can consider the option to delete all logs by “temporary” set the database Recovery mode to Simple and try another shrink.


But Keep in mind that following these steps might result in data loss and you’ll not be able to recover data at a point in time 


  • 4. Right-click the database and select Properties -> Options.
  • 5. Set the recovery model  Simple and exit the menu.


  • 6. Right-click the database again and select Tasks -> Shrink -> Files.
  • 7. Change the type to Log.
  • 8. Under Shrink action, select Release unused space and click OK.


  • 9. When the process completes, switch the recovery model back to Full or Bulk-Logged and take a full database backup.








Comments

Popular posts from this blog

D365FO – AX – Update Data Entity Target Entity fields with X++

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O