> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/troubleshooting/split-or-missing-data.md).

# A point's data is split or has gaps

Trends show gaps or a point appears to stop, because the same point is logged under two point IDs. Fix the equipment name and merge the data.

When customers view the data in DATRAN Trending, or generate reports etc., they may end up with apparent gaps in their data when in actuality all the data is there, it's just split across different point IDs. This happens when points are named slightly differently, with trailing whitespace on the **Equip Name** property.

{% hint style="info" %}
**Applies to:** DATRAN VI. In V6.77 and older the SQL Database handles inconsistencies in the formatting of strings in the configuration of logging points; in V6.78 the same problem creates problems with handling persistent queue files, see [unrecoverable files](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/troubleshooting/unrecoverable-files.md).
{% endhint %}

## Why it happens

SQL Server ignores case and trailing spaces when comparing text, so `My Point`, `MY POINT` and `My Point` all match. Spaces inside the text do count.

A logged point (`_Log_Analogue_`, `_Log_Digital_`, `_Log_Event_`, or a point in a `_Comms_Hist_Data_`) is identified by its site, equipment and point names. Two tables store it:

* **tblPoint**: the Equip Name and Point Name are concatenated to form the strPoint entry, and each combination maps to a unique iPointId.
* **tblPoints**: the Equip Name and Point Name are kept as separate fields (strEquipName and strPoint), with supplementary information like scaling, units, etc.

So `My Equip` and `My Equip` map to a single entry in tblPoints, but to different entries in tblPoint. The two points are logged under different point IDs, and are considered logically distinct from the perspective of clients of the database (for example DATRAN Trending and Reporting). Only trailing spaces on the equipment name cause this; differences in the site or point name are ignored.

## Fix it

1. **Correct the Equip Name property** of the points with trailing whitespace.
2. **Find the two point IDs** in tblPoint: the "good" one and the "bad" one.
3. **Copy the bad point's data to the good point ID.** For digitals, copy both tblEvent and tblDigital; for analogues, only tblAnalog. For example, with good ID 174432 and bad ID 171499:

   ```sql
   INSERT INTO [tblEvent] ([dtTimeStamp], [strType], [iPointId], [strCause], [iOperatorId])
   SELECT [dtTimeStamp], [strType], 174432, [strCause], [iOperatorID]
   FROM [tblEvent] WHERE [iPointId] = 171499

   INSERT INTO [tblDigital] ([iPointId], [dtStart], [dtStop], [dtAcknowledged], [strAcknowledgedBy])
   SELECT 174432, [dtStart], [dtStop], [dtAcknowledged], [strAcknowledgedBy]
   FROM [tblDigital] WHERE [iPointId] = 171499
   ```
4. **Delete the data for the “bad” point,** and optionally the “bad” point itself:

   ```sql
   DELETE FROM [tblEvent] WHERE [iPointId] = 171499
   DELETE FROM [tblDigital] WHERE [iPointId] = 171499
   DELETE FROM [tblPoint] WHERE [iPointId] = 171499
   ```

Back up the database first, and double-check the IDs: deleting the wrong ID can't be undone.

## Other reasons for gaps

* **Logging didn't reach SQL Server:** see [Trending shows no new data](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/troubleshooting/no-new-data.md).
* **RTU log records under a generic name:** after a logged point is deleted from `_Comms_Hist_Data_`, its remaining records go to a generic point such as `{site} {equip} RAI1`. See [Changing the logging configuration](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/rtu-data-logging.md#changing-the-logging-configuration-no-longer-loses-data).
* **The RTU log filled up** before DATRAN collected it, so the oldest records were overwritten. See [Data logging and the archive log](https://help.qtech.co.nz/datran/datran-telemetry/datran-xl4-plus-rtu/data-logging.md).

## Still not working? Contact QTech

Email <techsupport@qtech.co.nz> with your DATRAN VI version, the site, equipment and point names, both point IDs, and the dates of the gaps.
