Shrinking a Database Log file through SQL

Often our DB logs grow out of hand and we are left with limited space; a common occurrence on dev boxes for AX. So among other remedies to get more space is shrink your database log files and you can do so by using the queries below. Make sure you back up your databases before you run this, make this a standard practice before changing/modifying any meta on your db servers. You can do this for both your trans and model databases for Dynamics AX 2012.

USE DynamicsAXDev_model;

GO

— Truncate the log by changing the database recovery model to SIMPLE.

ALTER DATABASE DynamicsAXDev_model

SET RECOVERY SIMPLE;

GO

— Shrink the truncated log file to 1 MB.

DBCC SHRINKFILE (DynamicsAXDev_model_Log, 1);

GO

— Reset the database recovery model.

ALTER DATABASE DynamicsAXDev_model

SET RECOVERY FULL;

GO

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s