‎03-22-2017 04:58 PM
‎07-26-2022 09:13 AM
Hi
This is an old post but I've referenced it 2ce recently and had to work around an error both times
Problem - tblNtlogMessage table grows and maxes out SQL express 10GB limit
I've reduced the log retention in settings but table size didn't change
Below used to clear tblNtlog table to -7 days, then delete records from tblNtlogMessage where the EventID is not in tblNtlog or tblHyperVLog
(had to include tblHyperVLog to avoid error [The DELETE statement conflicted with the REFERENCE constraint "FK_tblHyperVLog_tblNtlogMessage"])
**This has not been approved by support - Use with caution**
I haven't seen any issues using it
Delete
FROM [lansweeperdb].[dbo].[tblNtlog]
WHERE [TimeGenerated] < GETDATE()-7
Delete
FROM [lansweeperdb].[dbo].[tblNtlogMessage]
WHERE [MessageID] NOT IN (SELECT DISTINCT [lansweeperdb].[dbo].[tblNtlog].[MessageID] FROM [lansweeperdb].[dbo].[tblNtlog])
AND
[MessageID] NOT IN (SELECT DISTINCT [lansweeperdb].[dbo].[tblHyperVLog].[EventMessageId] FROM [lansweeperdb].[dbo].[tblHyperVLog])
‎06-02-2017 12:59 AM
DELETE TOP (3000000) FROM [lansweeperdb].[dbo].[tblNtlog]
WHERE [TimeGenerated] < GETDATE()-180
DELETE FROM [lansweeperdb].[dbo].[tblNtlogMessage]
WHERE [MessageID] NOT IN (SELECT DISTINCT [lansweeperdb].[dbo].[tblNtlog].[MessageID] FROM [lansweeperdb].[dbo].[tblNtlog])
‎03-27-2017 05:33 AM
‎03-26-2017 09:44 PM
‎03-25-2017 09:12 AM
‎03-25-2017 09:08 AM
‎03-25-2017 03:32 AM
‎03-23-2017 08:41 AM
delete from tblntlog where tblNtlog.TimeGenerated > Current_TimeStamp
‎03-23-2017 08:25 AM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now