Issue
How do I set up a Continuum system to do automatic log truncation to save database space?
Product Line
Andover Continuum
Environment
Continuum Trend logs
Cause
Database maintenance.
Resolution
Setting up Automatic Log Truncation with SQL Server and MSDE Database
MSDE Engine
For MSDE, you can download the Stand Alone MSDE Database Utilities from Buildings Download Center.
These utilities are capable of automatically truncating the logs, as well making automated backups, checking for low hard drive space, etc.
SQL Server
For full SQL Server, you can easily create a scheduled Job. Details are described below.
To create a scheduled Job that will truncate the Continuum logs in the SQL Server:
- Open up SQL Enterprise Manager (Note that the SQL Server Agent service must be running in order to create a Job)
- Highlight the Continuum database
- From the Menu, select Tools \ Job Scheduling
- A wizard opens: "Welcome to the Create Job Wizard." Click Next
- Select Transact-SQL Command, Click Next
- For the Database Name, select ContinuumDB (or whatever the name of the DB is)
- In the large white space for the Transact-SQL Command, cut and paste the code from our web site:
****** Replace 90 with the number of days to maintain in each log ********
delete from accessevent where DATEDIFF(day, timestamp, getdate()) > 90 delete from activityevent where DATEDIFF(day, timestamp, getdate()) > 90 delete from alarmevent where DATEDIFF(day, timestamp, getdate()) > 90 delete from errorevent where DATEDIFF(day, timestamp, getdate()) > 90
- Click Next
- On the next screen, you are asked when you do want to run this job
- Select "On a recurring basis" and hit the Schedule button
- On the Schedule page, set up whatever schedule you desire
- Click OK to close the Schedule Page • Click Next
- On the Job Notifications screen, you can choose (if you want) any email or net send alerts. This is optional • Click Next
- In the final page, you are given a summary of the Job you have just created and you can change the name of your Job to anything you want. It might be a good idea to give it a more descriptive name like "Weekly Log Truncation"
- Click Finish and you are done. You should get a message that the job was created successfully.
- To verify that the Job is running correctly, you can go to the Enterprise Manager of SQL Server and click on the Management Folder, then expand the SQL Server Agent folder and click on Jobs. On the right-hand pane, you will see a list of created jobs. Scroll down and find the job that you just created. You can get information about the history of the Job, whether it ran successfully or not.