→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
eXPlosion
Engaged Sweeper
Is there a way to delete table entries that are newer than X day?

truncate table tblntlogevent
where date = X

Something like this.
1 ACCEPTED SOLUTION
Bruce_B
Lansweeper Alumni
Truncate cannot be run with a condition, it will remove all rows from a table (among other things).

You'd need to use a Delete script with a where clause instead, be aware that tblNtLog can have many many rows, and this query could cause a spike in your transaction log.

I'd recommend instead making use of the History cleanup options under Configuration\Server Options. You can specify an interval for eventlogs to be cleaned up. Modify the interval and restart the Lansweeper Server service via services.msc if you'd like to trigger the cleanup immediately. Otherwise it will run at some point in the next 24 hours.

View solution in original post

4 REPLIES 4
Bruce_B
Lansweeper Alumni
Select * from tblNtlog where timegenerated <= getdate()-30 will select all tblNtLog entries older than 30 days. Information on our tables and fields can be found in our database documentation: https://www.lansweeper.com/knowledgebase/accessing-the-lansweeper-database-documentation/



Again though, I recommend letting the automatic cleanup handle this. Run Delete, Insert or Update queries against your Lansweeper database at your own risk.
eXPlosion
Engaged Sweeper
Anyone?
eXPlosion
Engaged Sweeper
What is create date attribute name in tables? Something like:

delete from tblntlogevent where date > 2019.05.16
Bruce_B
Lansweeper Alumni
Truncate cannot be run with a condition, it will remove all rows from a table (among other things).

You'd need to use a Delete script with a where clause instead, be aware that tblNtLog can have many many rows, and this query could cause a spike in your transaction log.

I'd recommend instead making use of the History cleanup options under Configuration\Server Options. You can specify an interval for eventlogs to be cleaned up. Modify the interval and restart the Lansweeper Server service via services.msc if you'd like to trigger the cleanup immediately. Otherwise it will run at some point in the next 24 hours.