Start a conversation

Delete old journals to shrink db

BACKUP First!!

Simpler option: DELETE FROM journal WHERE time < GETDATE() - (365 * X)
where X is number of years ago

To delete the Journal (receipts) older than 5 years, enter this into a new query in SO/HQ Admin;

DELETE FROM Journal WHERE Time < GETDATE() - 1825

3 years would be:

DELETE FROM Journal WHERE Time < GETDATE() - 1095 

2 years would be:

DELETE FROM Journal WHERE Time < GETDATE() - 730

Then run shrink routine by replacing MYDATABASE below with correct db name and run entire script.

DECLARE @Database varchar(50)

SET @Database = 'MYDATABASE'
/* Truncate log */DUMP TRANSACTION @Database WITH TRUNCATE_ONLY
/* Shrink Database */DBCC SHRINKDATABASE (@Database)

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Dave J

  2. Posted
  3. Updated

Comments