Shrink all databases on server (sql)

Database server

About a month ago, I got a call from a client of mine saying he has 2 database servers, each holding about 150 databases.

The servers were both SQL Server 2008, he had 2 HD’s with 74GB each and there was absolutely no space on any of them.

After a short research I found that the backup files were absolutely huge and fill the disk up to a point that the server had no space to store any more data and the website connected to that database crashed.

Without going too much into details why these things happen (bad programming) I will give you a method to fix this.

It is recommended to backup your databases to an external HD before doing this, this way you will have the full backup at all times.

Simply run this script, your databases (all of them) will shrink the log file, creating more room on the HD for you to use.

Good luck

Developer