...
Code Block | ||
---|---|---|
| ||
DECLARE @DeleteBefore DATETIME = CAST('2000-12-31T00:00:00' AS DATETIME)
DELETE FROM Contexts WHERE ContextType = 'ElementContext' AND FlowContextId IN (SELECT Id FROM Contexts WHERE ContextType = 'FlowContext' AND CreateTime < @DeleteBefore);
DELETE FROM ContextIndices WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE ContextType = 'FlowContext' AND CreateTime < @DeleteBefore);
DELETE FROM ContextLogs WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE ContextType = 'FlowContext' AND CreateTime < @DeleteBefore);
DELETE FROM Contexts WHERE ContextType = 'FlowContext' AND CreateTime < @DeleteBefore;
DELETE FROM PerformanceRecords WHERE [Time] < @DeleteBefore;
DBCC INDEXDEFRAG(0, 'Contexts')
DBCC INDEXDEFRAG(0, 'ContextIndices')
DBCC INDEXDEFRAG(0, 'ContextLogs')
DBCC INDEXDEFRAG(0, 'PerformanceRecords') |
...