Issue
Assigning historical data associated with an existing meter that is connected to Power Monitoring Expert system to a new device.
Note: Both old and new meters must be from the same meter family series. Different meter series may log values under different quantities.
Product Line
Power Monitoring Expert 7.2.x
Power Monitoring Expert 8.x
Power Monitoring Expert 9.0
Power Monitoring Expert 2020
Power Monitoring Expert 2021
Power Monitoring Expert 2022
Power Monitoring Expert 2023
Environment
SQL Server Management Studio
Cause
A customer has an old meter and added a new meter from the same meter family series and wants the historical data that has been logged in the database to be associated with the new meter as well.
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.*
A few SQL queries need to be executed in order to move and combine the old historical data from the old device associated with existing sourceID to the new device, and associate it with the new sourceID created by the ION Log Inserter service. For this procedure, follow the below steps in order:
1) Go to Windows services and stop the "ION Log Inserter" service.
2) Note the old and new device Source names. The source names can be found either from devices page in Management Console (unless the device has been renamed), or by viewing the "Name" column in the "dbo.Source" table found in the ION_Data database (SQL Server Management Studio).
In the example below, the 2 device names will be called "Group.OldDevice" and "Group.NewDevice". ("Group.OldDevice" being the existing meter and "Group.NewDevice" being the replacement meter)
3) Update the following SQL queries with the specific devices names noted in step 2, and run them in SQL Server Management Studio.
a) UPDATE [ION_Data].[dbo].[DataLog2]
SET [SourceID]=(SELECT [ID] FROM [ION_Data].[dbo].[Source] WHERE [Name]='Group.NewDevice')
WHERE [SourceID]=(SELECT [ID] FROM [ION_Data].[dbo].[Source] WHERE [Name]='Group.OldDevice')
b) UPDATE [ION_Data].[dbo].[EventLog2]
SET [SourceID]=(SELECT [ID] FROM [ION_Data].[dbo].[Source] WHERE [Name]='Group.NewDevice')
WHERE [SourceID]=(SELECT [ID] FROM [ION_Data].[dbo].[Source] WHERE [Name]='Group.OldDevice')
c) UPDATE [ION_Data].[dbo].[WaveformLog2]
SET [SourceID]=(SELECT [ID] FROM [ION_Data].[dbo].[Source] WHERE [Name]='Group.NewDevice')
WHERE [SourceID]=(SELECT [ID] FROM [ION_Data].[dbo].[Source] WHERE [Name]='Group.OldDevice')
4) Start the "ION Log Inserter" service.
After associating the existing historical data with the new sourceID, the old sourceID may be deleted along with all its data.
Please reference FA210105 for instructions on deleting the data.