Issue
To manage drive space limitations, it is desirable to only keep a specified amount of historical data available for reporting. For some customers, this may be 1, 2, 3...10 years. However, it is not desirable to create archive databases that have to then be deleted themselves.
Product Line
Power Monitoring Expert 7.x
Power Monitoring Expert 8.x
*NOTE: This method will NOT work for versions newer than PME 8.x due to modifications made within the database formatting.
*NOTE: This method will NOT work for SQL Express systems due to the missing SQL Agent service.
Environment
SQL Server, Power Monitoring Expert
Cause
An archive database takes up additional space on the hard drive, therefore it is desirable to only remove old data on a periodic basis.
Resolution
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.*
The attached SQL script can be added to the database as a Stored Procedure and then configured to be triggered by an SQL Agent job to run.
1. Save the attached file that matches the version of PME installed on the server
2. Open SQL Server Management Studio
2. Connect to the ION SQL Server instance (providing appropriate credentials to modify ION_Data)
3. Go to File > Open > File
4. Browse to the saved file from this article on the PME server and open
5. Adjust the time frame as appropriate to this system.
By default, this Stored Procedure will remove all data older than 3 years from the date ran.
DATEADD(YEAR, -3, GETDATE())
EXAMPLE: If this system needs to retain 6 years in the live database this line of code should be changed to
DATEADD(YEAR, -6, GETDATE())
6. Click Execute
7. In the left pane expand Databases>ION_Data>Programmability>Stored Procedures and ensure that dbo.DataTrimSchedule has been created.
8. Expand SQL Server Agent
9. Right-click Jobs > New Job...
10. Name = ION_Data Trim Schedule (This is an arbitrary name. Just be certain to note)
11. Click Steps > New
12. Step name = Trim Data
13. In the Command pane type EXECUTE [dbo].[DataTrimSchedule]
14. Click Schedules > New
15. Name = Trim Data
16. Set the frequency that meets this system's needs. To just keep a rolling X (where X is the number chosen by the customer) amount of years in the database this could be set to monthly. If it is desirable to
keep a full previous X years this will need to be run yearly on January 1st.
17. Click OK, then Click OK on the Job window.
The system is now configured to remove "old" data on a scheduled basis and this data cannot be reclaimed after removal.
To manage drive space limitations, it is desirable to only keep a specified amount of historical data available for reporting. For some customers, this may be 1, 2, 3...10 years. However, it is not desirable to create archive databases that have to then be deleted themselves.
Product Line
Power Monitoring Expert 7.x
Power Monitoring Expert 8.x
*NOTE: This method will NOT work for versions newer than PME 8.x due to modifications made within the database formatting.
*NOTE: This method will NOT work for SQL Express systems due to the missing SQL Agent service.
Environment
SQL Server, Power Monitoring Expert
Cause
An archive database takes up additional space on the hard drive, therefore it is desirable to only remove old data on a periodic basis.
Resolution
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.*
The attached SQL script can be added to the database as a Stored Procedure and then configured to be triggered by an SQL Agent job to run.
1. Save the attached file that matches the version of PME installed on the server
2. Open SQL Server Management Studio
2. Connect to the ION SQL Server instance (providing appropriate credentials to modify ION_Data)
3. Go to File > Open > File
4. Browse to the saved file from this article on the PME server and open
5. Adjust the time frame as appropriate to this system.
By default, this Stored Procedure will remove all data older than 3 years from the date ran.
DATEADD(YEAR, -3, GETDATE())
EXAMPLE: If this system needs to retain 6 years in the live database this line of code should be changed to
DATEADD(YEAR, -6, GETDATE())
6. Click Execute
7. In the left pane expand Databases>ION_Data>Programmability>Stored Procedures and ensure that dbo.DataTrimSchedule has been created.
8. Expand SQL Server Agent
9. Right-click Jobs > New Job...
10. Name = ION_Data Trim Schedule (This is an arbitrary name. Just be certain to note)
11. Click Steps > New
12. Step name = Trim Data
13. In the Command pane type EXECUTE [dbo].[DataTrimSchedule]
14. Click Schedules > New
15. Name = Trim Data
16. Set the frequency that meets this system's needs. To just keep a rolling X (where X is the number chosen by the customer) amount of years in the database this could be set to monthly. If it is desirable to
keep a full previous X years this will need to be run yearly on January 1st.
17. Click OK, then Click OK on the Job window.
The system is now configured to remove "old" data on a scheduled basis and this data cannot be reclaimed after removal.