Zum Inhalt springen
SQL-Tipp für Change Log

How-To: Shrink Tables like 'Change Log Entry'

Daniel Gorski
Daniel Gorski 10. Februar 2021
2 Min. Lesezeit

... and other tables. I've used it for my demo-db. Take it "as is" and at your own risk.

Keep tables like "Change Log Entry" or "Job Queue Log Entry" as empty as possible - if you want to ;-)!

Use e.g. RapidStart to see how many records are stored:

RapidStart

I've used the DATEADD-Command in my sql-statement to add a date/time interval to a specific date which returns a date:

select DATEADD(day, -360, SYSDATETIME()) as "360DaysAgo";

throws:

360DaysAgo

2020-02-16 13:41:05.1657480

Open your Microsoft SQL Server Management Studio and run this statement to see how many records are older than 360 days:

(Replace DBNAME and COMPANYNAME with your specific values)

Use [DBNAME]

select *
from
[dbo].[COMPANYNAME$Job Queue Log Entry]
where
[dbo].[COMPANYNAME$Job Queue Log Entry].[Start Date_Time] < DATEADD(day, -360, SYSDATETIME())

select *
from
[dbo].[COMPANYNAME$Change Log Entry]
where
[dbo].[COMPANYNAME$Change Log Entry].[Date and Time] < DATEADD(day, -360, SYSDATETIME())

You can also delete them by throwing a delete-statement for records which are older than six months. (Use it at your own risk. Take a backup of your database before running this.)

Hint: You are going to use this code as a sample only and at your own risk. Support is not provided for this.

Use [DBNAME]

delete
from
[dbo].[COMPANYNAME$Job Queue Log Entry]
where
[dbo].[COMPANYNAME$Job Queue Log Entry].[Start Date_Time] < DATEADD(month, -6, SYSDATETIME())

delete
from
[dbo].[COMPANYNAME$Change Log Entry]
where
[dbo].[COMPANYNAME$Change Log Entry].[Date and Time] < DATEADD(month, -6, SYSDATETIME())
how-to
performance
sql
business central
database cleanup
changelog
performance
GoBD-konforme Archivierung mit Business Central und SharePoint ohne DMS

Architektur

Revisionssicher archivieren ohne DMS? Wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen

Warum „GoBD" oft vorschnell zum K.O.-Kriterium wird – und wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen.

Weiter lesen: Revisionssicher archivieren ohne DMS? Wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen
Weiter lesen: Revisionssicher archivieren ohne DMS? Wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen
Modulare ERP-Architektur für skalierbare Unternehmenssoftware

Architektur

Mehr als nur Warenwirtschaft - die Landtechnik Lösung

ERP-Systeme wurden jahrelang als Monolithen verkauft. Die eigentliche Stärke moderner Plattformen wie Business Central liegt jedoch in der Modularität - und gen

Weiter lesen: Mehr als nur Warenwirtschaft - die Landtechnik Lösung
Weiter lesen: Mehr als nur Warenwirtschaft - die Landtechnik Lösung