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
Azure Communication Services SMTP with Scanner

Using Azure Communication Services SMTP with Your Scanner or Printer

Need to send scans via email from your office scanner? Azure Communication Services provides a reliable SMTP relay that works with any device supporting SMTP au

Weiter lesen
Weiter lesen
XRechnung Einrichtung in Business Central

XRechnung in Business Central einrichten: Schritt für Schritt zur E-Rechnung

Ab 2025 wird die E-Rechnung im B2B-Bereich in Deutschland Pflicht. Wir zeigen Ihnen, wie Sie XRechnung in Business Central einrichten – mit E-Beleg-Dienst, Work

Weiter lesen
Weiter lesen