Decompressing WinCC TagCompressed Archive Segments (BinValues) Without Original Project
WinCC SQL archive segments (.mdf/.ldf) store historical process data as proprietary compressed binary BLOBs in the TagCompressed.BinValues column that cannot be decoded by raw SQL. To extract readable timestamps and engineering values into CSV or Excel without the original project, attach the database files to a system equipped with the WinCC OLE-DB Provider (via WinCC/Connectivity Pack or DataMonitor) and query data via ADO.
Table of Contents
- Forensic Data Recovery and Binary Compression Architecture
- Why Raw SQL Queries Fail on TagCompressed Tables
- Step-by-Step Data Extraction and Decompression Workflow
- WinCC Data Extraction Architecture Comparison
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Forensic Data Recovery and Binary Compression Architecture
In process forensic audits, equipment warranty claims, or plant litigation, engineering consultants often receive standalone Microsoft SQL Server database files:
* Primary data file: ArchiveName.mdf
* Transaction log file: ArchiveName.ldf
* Origin: SIMATIC PCS 7 / WinCC Tag Logging historical archive segments.
* Constraint: The originating engineering multiproject, source graphics, and WinCC project files (.mcp) are unavailable.
When an analyst attaches these files to a standard Microsoft SQL Server instance (using SQL Server Management Studio) and queries the historical tables, they find that instead of standard relational rows with floating-point values, data is stored inside a table named TagCompressed. Inside this table, the column BinValues contains dense binary large objects (BLOBs) consisting of raw hexadecimal streams.
Standard SQL queries such as SELECT Timestamp, BinValues FROM TagCompressed yield unreadable hexadecimal strings. The analyst requires a method to transform these binary archives into plain CSV or Excel tables containing exact UTC timestamps, floating-point process values, and quality codes.
Why Raw SQL Queries Fail on TagCompressed Tables
The inability of standard database tools to unpack historical values stems from Siemens proprietary compression algorithms:
-
Swinging Door and Delta-Time Binary Compression:
* To achieve high-speed logging (thousands of values per second) without saturating hard disk throughput, WinCC Tag Logging does not write individual SQL rows for each sample.
* Instead, WinCC packages time-series blocks into compressed binary buffers (typically representing 1 minute to 1 hour of data per tag) containing header metadata, reference baselines, delta timestamps, and bit-packed floating-point increments. -
The Role of the WinCC OLE-DB Provider:
* The decompression algorithm is embedded exclusively inside the WinCC OLE-DB Provider (WinCCOleDBProvider.dll).
* When queried using WinCC OLE-DB syntax (TAG:R,...), the provider reads the binary BLOBs fromTagCompressed.BinValues, parses the proprietary byte streams in RAM, reconstructs the time-series curve, and returns a standard relational schema with columns:Timestamp(UTC DateTime)RealValue(Double / Float)Quality(Hexadecimal Status / Quality Code)Flags(System Flags)
-
Software Package Requirements:
* Access to the WinCC OLE-DB Provider without running the full WinCC SCADA runtime requires one of two Siemens software packages:- SIMATIC WinCC / Connectivity Pack
- SIMATIC WinCC / DataMonitor
Step-by-Step Data Extraction and Decompression Workflow
1. Attach Raw Archive Segments in SQL Server
- Copy
ArchiveName.mdfandArchiveName.ldfto the SQL Server data directory. - In SQL Server Management Studio (SSMS), execute the attachment script:
sql EXEC sp_attach_db @dbname = N'Archive_Segment_01', @filename1 = N'C:\WinCC_Data\ArchiveName.mdf', @filename2 = N'C:\WinCC_Data\ArchiveName.ldf'; - Inspect table
ArchiveTagCataloginside the attached database to view the internalTagIDmappings corresponding to process tag names.
2. Prepare the Extraction Station
- Deploy a workstation running Windows with WinCC Connectivity Pack Client installed.
- Ensure the WinCC OLE DB Provider is registered.
- Verify that the SIMATIC WinCC/Connectivity Pack license is present in Automation License Manager.
3. Query Decompressed Data Using ADO / VBScript or Python
Create an extraction script that queries the attached archive segment via ADODB using the WinCC OLE-DB Provider:
Dim conn, rs, connStr, sqlQuery
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
' Connect to the attached SQL database catalog via WinCC OLE-DB
connStr = "Provider=WinCCOLEDBProvider.1;Catalog=Archive_Segment_01;Data Source=.\WINCC"
conn.Open connStr
' Query decompressed tag data across time boundary
sqlQuery = "TAG:R,(1;2;3),'2016-01-01 00:00:00.000','2016-01-02 00:00:00.000'"
rs.Open sqlQuery, conn
' Export to CSV file
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("C:\WinCC_Data\Exported_Data.csv", True)
outFile.WriteLine "TagID,Timestamp,Value,Quality"
Do While Not rs.EOF
outFile.WriteLine rs("TagID") & "," & rs("Timestamp") & "," & rs("RealValue") & "," & rs("Quality")
rs.MoveNext
Loop
outFile.Close
rs.Close
conn.Close
4. Alternative: Siemens Extended Technical Support
If your organization does not possess a WinCC Connectivity Pack license or an active WinCC engineering environment:
* Siemens Industry Customer Support offers an Extended Technical Support consulting service.
* Engineers can submit raw .mdf/.ldf segments to Siemens support specialists who decompress and convert the binary archives into customer-specified CSV or Excel datasets for an hourly professional service fee.
WinCC Data Extraction Architecture Comparison
SELECT).mdf/.ldf).mcp project)Verification
- Run the ADO extraction script against the attached database segment.
- Confirm the generated
Exported_Data.csvcontains human-readable timestamps and decimal values (e.g.2016-01-01 04:15:30.125, 45.82, 16#80). - Cross-reference the extracted values against known plant physical limits (e.g., tank capacity, temperature ranges).
- Verify that Quality Code
16#80(Good) is maintained across valid operational records.
Limitations and Operational Precautions
- Missing Tag Catalog Names: In standalone
.mdfsegments, tag names may be referenced only by numericTagID. IfArchiveTagCatalogis unreadable or truncated, you must identify process variables by correlatingTagIDwith electrical P&ID loop sheets. - Database File Version Compatibility: An
.mdffile generated by WinCC V7.3 (SQL Server 2008 R2) cannot be attached to an older SQL Server 2005 instance. Always attach to an identical or newer SQL Server version. - Commercial and Licensing Compliance: The WinCC OLE DB Provider is commercially licensed under WinCC/Connectivity Pack (
6AV6371-1DH07-3AX0). Using the provider in production without appropriate licensing violates Siemens End User License Agreements.
Engineer FAQ
Can I decompress BinValues using a custom C# or Python script without Siemens software?
No. The exact mathematical compression algorithm and bit-packing layout utilized in WinCC BinValues is proprietary and unpublished. External applications must invoke the WinCC OLE-DB Provider.
What is the difference between fast and slow archive segments?
Fast archives store high-frequency cyclical samples (< 1 minute), while slow archives store aggregated, compressed, or long-cycle data. Both utilize the same underlying TagCompressed schema.
How do I find which TagID corresponds to my instrument tag?
In SQL Server Management Studio, execute: SELECT * FROM ArchiveTagCatalog or query table CC_ArchiveTag inside the attached database segment.
Technical References
- SIMATIC WinCC V7.3 WinCC/Connectivity Pack System Manual
- SIMATIC WinCC V7.3 Tag Logging System Architecture Manual
- Microsoft SQL Server: Attaching and Detaching Databases (Transact-SQL)
- Siemens Industry Online Support: Exporting WinCC Process Values via OLE DB (SIOS Entry ID 109780813)
Related Articles
- Resolving 'ActiveX Component Cannot Create Object' in WinCC OLE-DB Queries
- WinCC Tag Logging Archive Configuration and Segment Size Calculation
- Process Historian Maintenance, Backup, and Disaster Recovery Procedures
Related Tags
- TagCompressed
- BinValues
- Connectivity Pack
- OLE-DB
- SQL Server
- Forensic Analysis