Atlantic Oak

How to shrink the SQL transaction log on a d365 dev environment

Recently the database transaction log on one of my Dynamics 365 for Finance and Operations development environments grew too large and when I tried doing a database synchronization operation it failed and gave me the following error:

System.Data.SqlClient.SqlException (0x80131904): The transaction log for database 'AxDB' is full due to 'LOG_BACKUP'.

This is because the drive where the SQL transaction log is stored is full. Since it is a development environment and we do not care about point in time restore, we can open SQL Server Management Studio (SSMS) and execute these commands to shrink the log:

ALTER DATABASE AxDB SET RECOVERY SIMPLE;

And then execute this:

USE AxDB;
GO
CHECKPOINT;
GO
CHECKPOINT;
GO
DBCC SHRINKFILE(AxDBCopy3_log, 1000); -- 1000 = 1GB
GO

AxDBCopy3_log is the name of the log file in my case. If you don't know the name of your log file you can right click on the AxDB database in SSMS and click on properties. You will find the name of your log file under the files page:

Database Properties AxDB

Dynamics 365 F&O Development Services

Does your dev team have too much on their plate? We can help by handling big or small Dynamics 365 customization projects at a competitive rate. Click here.

File based integration system for Dynamics 365 Finance and Operations

The Atlantic Oak Document Exchange System allows your Dynamics 365 for Finance and Supply Chain Management system to directly pull or push XML or flat files to and from external systems via SFTP, FTP, FTPS, Azure Storage, Azure Files and other file servers. Click here.

×