Shrink Transaction Log

At a company I worked, they were in the process of setting up ERP software that was bought by their  management.

Regardless the quality (or lack thereof) of the software that was installed for use at the company, one of my duties was to care for the good maintenance of the SQL Servers.

Well, long story short, this ERP software that was installed at the company I worked for created a log of 30 GB for a database of 1 GB.

It was outrageous.

So in order to prevent it to grow further I created a job that shrink the log daily.

Although it is pretty straightforward to do this for a single database, I decided to raise the bar a bit and create the same procedure for every single database on all our servers.

How to do this? It’s a two steps procedure.

First I ran a query that creates the SQL commands to generate the procedures on every database on the server.

Then I create a job that will run on the server daily, just prior to the full database backup, to keep the log file small.

Comments