WinCC Tag Logging: Find Archive Database and Export CSV

David Krause14 min read
SiemensTutorial / How-toWinCC
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

WinCC Tag Logging: Locating the Archive Database and Exporting to CSV

WinCC does not write tag logging values to comma-separated text files. From the legacy V6.x runtime up through the current WinCC Unified (TIA Portal V20) line, the historian is implemented as a Microsoft SQL Server database. Operators who need a portable artifact for reporting, statistical analysis, or hand-off to MES layers must deliberately export that data to CSV (or Excel). This reference describes exactly where the raw archive lives, which SQL files are touched, the export mechanisms shipped with each major version, and the license and configuration constraints that determine which path is available on a given project.

Architectural note. Any direct read of the WinCC archive database (TCC, CC_LoggingFast, CC_LoggingSlow, CC_Environmental) outside the WinCC runtime or its licensed OLE-DB provider is unsupported. Always use the in-built export functions or the WinCC OLE-DB connector (AS-OS Engineering license) to avoid corrupting segments that the runtime is actively writing.

1. WinCC Tag Logging Architecture Overview

Tag Logging is split into two acquisition cycles, each persisted in its own SQL Server database:

  • Tag Logging Fast – acquisition and archive cycle in the millisecond-to-second range. Used for fast-changing process values (pressures, flows, currents).
  • Tag Logging Slow – acquisition and archive cycle in the seconds-to-minutes range. Used for slowly changing values (temperatures, counters, setpoints).

Both databases are created and maintained by the WinCC ArchiveManager service. The runtime writes via SQL Server, segments the tables over time, and rotates the on-disk files. Tag Logging in WinCC V6/V7 is a SQL Server Express or full SQL Server backend; the exact storage location is configurable in the project properties.

2. Where the Archive Files Live (V6 / V7)

The default path is inside the WinCC project directory, under the ArchiveManager subfolder:

C:\Siemens\WinCC\<ProjectName>\ArchiveManager
   ├── TagLoggingFast\
   │     ├── CC_LoggingFast.mdf
   │     └── CC_LoggingFast_log.ldf
   └── TagLoggingSlow\
         ├── CC_LoggingSlow.mdf
         └── CC_LoggingSlow_log.ldf
File Type Role
CC_LoggingFast.mdf Primary data file Holds the segmented fast-cycle archive tables and their index pages.
CC_LoggingFast_log.ldf Transaction log SQL Server transaction log for the fast database; necessary for crash recovery.
CC_LoggingSlow.mdf Primary data file Holds the slow-cycle archive tables.
CC_LoggingSlow_log.ldf Transaction log Transaction log for the slow database.
CC_Environmental.mdf Primary data file Created in V7 projects using the Environmental option; stores environmental/system data.
Do not edit, copy, or detach these files while the runtime is active. The WinCC ArchiveManager attaches both databases at project start and the SQL Server instance (typically WINCC \ SQLEXPRESS) holds locks on them. Stop the WinCC runtime (or at least the Archiving subsystem) before manipulating .mdf/.ldf files.

3. Verifying the Storage Path in the Project

Confirm the path that the active project is using:

  1. Open the WinCC Explorer on the engineering or server station.
  2. Right-click ComputerPropertiesGraphics Runtime tab.
  3. Note the Start picture and the Project path.
  4. Right-click Tag LoggingProperties (or open the Tag Logging editor).
  5. Open Archive ConfigurationTimelines / Archives. The Storage location and per-archive path fields are shown here; in V7 the path can be redirected to a UNC share.

For a quick check from the command line:

dir /s "C:\Siemens\WinCC\<ProjectName>\ArchiveManager\*.mdf"
dir /s "C:\Siemens\WinCC\<ProjectName>\ArchiveManager\*.ldf"

If you do not see CC_LoggingFast.mdf/CC_LoggingSlow.mdf, the project is using a custom path or the runtime has not yet started archiving. Trigger an acquisition cycle (set a tag with archive=1 and wait one cycle) and re-check.

4. Why You Will Not Find a CSV on Disk

There is no .csv file written by Tag Logging in any version of WinCC. The runtime does the following with a logged tag value:

  1. Stores the raw value into the in-memory archive buffer of the Tag Logging runtime.
  2. Flushes the buffer at the configured archive cycle to the SQL segment table for the current time slice.
  3. Closes and creates new segments as time progresses (segmentation is configured in the Archive Configuration editor).

Anything you can open in a text editor (*.csv, *.txt) must be produced by an explicit export step – either interactively in the operator faceplate, via the WinCC DataMonitor, via the WinCC OLE-DB provider, or via a user-written VBScript/C script in the runtime.

5. Exporting to CSV – Method Matrix

Method WinCC Version Trigger Output License
OnlineTrendControl right-click → Export Data V6.2 SP2 and later, V7.x Operator click in runtime CSV (per trend window's selected range) WinCC RT/RC license
WinCC DataMonitor (web) V6.2 SP2+, V7.x Browser-based download CSV/XLSX via Trends & Alarms DataMonitor license
VBScript (C/C# for V7) with Export on OnlineTrendControl V6.x, V7.x Scheduled / event-driven CSV at user-defined path WinCC RT/RC license
OLE-DB provider WinCC_OLEDBProvider.1 + CC_READTABLE V6.2+, V7.x External application / script Any format (consumer-controlled) WinCC AS-OS Engineering (Connectivity Pack)
WinCC Unified: Tag Logging export from a Trend Control V16+ (Unified, TIA Portal) Operator click in Unified runtime CSV/XLSX Unified RT/RC

6. Interactive CSV Export from the OnlineTrendControl (V6.2 SP2+)

The fastest path. From WinCC V6.2 SP2 onward, the OnlineTrendControl offers a built-in export:

  1. Open the WinCC Runtime containing the configured OnlineTrendControl picture.
  2. Right-click inside the trend window.
  3. Select Export DataCSV File (or Export Data… in localized builds).
  4. In the dialog, set:
    • Time range (Start/End – based on the trend's visible time base).
    • Columns (the curves currently assigned to the trend control).
    • Decimal separator and field separator (comma or semicolon – critical for European locales where Excel expects semicolons).
  5. Choose the destination path (network share or local).
  6. Confirm with OK. The runtime writes the CSV and opens it in the associated application.

Resulting file (header depends on curve names and timestamp format):

Timestamp;TagA;TagB;TagC
2024-05-12 08:00:00.000;12.34;0.987;1450
2024-05-12 08:00:01.000;12.36;0.989;1451
Locale trap. On a German/French/Spanish operator station, the system decimal separator is comma. The default CSV export will also use comma as field separator, producing a single column in Excel. Force the field separator to ; in the export dialog or change the system separator before the export.

7. WinCC DataMonitor Export

WinCC DataMonitor is the web-based client for trend and alarm views. On V6.0 SP2 a DataMonitor client can connect and request a CSV export of a trend view. The data path is the same archive; the export is a server-side action.

  1. Install the DataMonitor server component on the WinCC server (separate installation media in the WinCC setup).
  2. Activate the DataMonitor web page in the WinCC project (Web Navigator / DataMonitor server settings).
  3. Open the DataMonitor URL in Internet Explorer/Edge: http://<WinCCServer>/DataMonitor/
  4. Log in with a user that has the DataMonitor – View and Export authorization.
  5. Open Trends & AlarmsTrends.
  6. Add the archive tags you want to export to a trend view.
  7. Click ExportCSV. The browser downloads the file.
License required. DataMonitor (also referred to as WinCC/WebNavigator successor for read-only access) requires the DataMonitor license on the WinCC server. Without the license, the page shows a watermark and the export buttons are disabled.

8. Scripted / Scheduled CSV Export (V6 / V7)

For unattended export – e.g. a daily CSV per shift – use VBScript inside a Global Action or a C action. The OnlineTrendControl exposes an Export method.

Setup prerequisites

  • Configure a picture with an OnlineTrendControl bound to the desired archive tags.
  • Open the picture in the runtime at least once to instantiate the control (it can be on a hidden start picture).
  • Configure a time range; Export exports the currently displayed time range.

VBScript example – daily export

' Global action, triggered daily via scheduler
Dim sFile, sRange, oTrend, oTimeRange

Set oTrend = ScreenItems("MyTrendControl")

' Define a 24 h time range ending "now"
Set oTimeRange = CreateObject("TrendTimeRange")
oTimeRange.TimeBase = 1            ' vbSecond = 0, vbMinute = 1, etc.
oTimeRange.Begin = DateAdd("h", -24, Now)
oTimeRange.End   = Now

sFile = "D:\Exports\<ProjectName>_" & _
        Year(Now) & Right("0" & Month(Now), 2) & _
        Right("0" & Day(Now), 2) & ".csv"

oTrend.Export sFile, oTimeRange, 0   ' 0 = CSV
Set oTrend = Nothing

C-script variant (WinCC V7) – use the ExportCSV() method exposed on the IWinCCTrendControl COM interface. See the WinCC V7 Information System under Working with WinCC > VBA for Automated Configuration > Examples > Exporting Data from the WinCC OnlineTrendControl.

Pitfall – local paths on a multi-user project. The runtime user must have write permission to the export path. If the export path is on a network share, prefer a UNC path (e.g. \\fileserver\reports\) and grant the WinCC service account modify rights. A relative path is resolved against the WinCC project directory.

9. Direct Database Access via the OLE-DB Provider

Power users, Excel Power Query authors, and reporting tools such as SSRS or Power BI connect to the archive using the WinCC OLE-DB provider. This is the only method that does not require the data to be displayed in a picture first.

  1. Confirm the WinCC AS-OS Engineering (a.k.a. Connectivity Pack) license is installed on the server.
  2. Build a connection string:
Provider=WinCCOLEDBProvider.1;
Catalog=CC_LoggingSlow_<ProjectName>_<TimeStamp>;
Data Source=.\WinCC;
User Id=<WinCCUser>;
Password=<Password>;
  1. Use the CC_READTABLE stored procedure or a direct SELECT against the dbo.TAG table (column VALUE, TIMESTAMP, QUALITY).
  2. Push the result set to CSV from the consumer (e.g. bcp, Power Query's Export to CSV, or SSRS subscription).

Catalog names follow the pattern CC_<ArchiveType>_<ProjectName>_<YYYY-MM-DD hh-mm-ss-fff>. The catalog is created on first archive start and stays for the lifetime of the project unless explicitly re-created.

Concurrent writer. Use WITH (NOLOCK) or set the transaction isolation level to READ UNCOMMITTED in the consumer query, otherwise long-running reports can block the ArchiveManager's writes and cause a back-log of archive segments.

10. WinCC Unified (TIA Portal V20) – Logging Tags

From TIA Portal V16 onward, WinCC Unified is the new generation runtime. Tag Logging is configured in the HMI Tags editor of the Unified device, under Logging. The runtime persists values to a built-in SQLite or PostgreSQL store (project- and version-dependent). The Configuring logging tags (RT Unified) – TIA Portal V20 documentation describes the editor, the compression options, and the export from a trend control.

Key differences versus classic V6/V7:

  • Logging tags are configured in the project tree under Runtime settings > Logging; there is no separate Tag Logging editor in Explorer.
  • Cascading logging tags (a logging tag whose Source is another logging tag via the Compression setting) become invalid after certain project modifications and must be re-defined. The TIA Portal V20 documentation explicitly notes: "If you are using cascading logging tags by having defined a source under 'Compression', the reference becomes invalid due to the copy process. Redefine the [source]."
  • Export is done from the Unified Trend Control: right-click → Export data → CSV/XLSX.
  • The underlying database is not exposed by default; for external reads use the Unified OLE-DB / OPC UA Historical Access interface.
Compressed source invalidation. If you copy a Unified HMI device or import logging tags from a global library, the Source reference of a compressed logging tag is broken. Symptoms: the logging tag shows "No valid value" or never updates. Fix: open the logging tag and re-select the source under Compression > Source, then recompile and download.

11. License Requirements Summary

Capability Required License
Run Tag Logging (write to the SQL archive) WinCC RT / RC (basic or specific count)
Operator CSV export from OnlineTrendControl WinCC RT / RC
Scripted export via VBScript/C WinCC RT / RC
DataMonitor read + CSV export (web) DataMonitor license on the server
OLE-DB direct access / external reporting AS-OS Engineering (Connectivity Pack)
OPC UA Historical Access to archive OPC UA Server license, plus AS-OS for unrestricted query

12. Troubleshooting Matrix

Symptom Likely Cause Corrective Action
No *.mdf files in ArchiveManager Runtime never started, or archive path redirected via Project Properties > Archive Configuration Check the configured path; start the runtime and wait one cycle; re-export from the editor
Files exist but the slow/fast DB size does not grow No archive tags configured, or all archive flags are off Open Tag Logging, check the Archive column for the tags; ensure a process value is being driven
CSV export button greyed out Missing DataMonitor license, or user lacks the Export CSV authorization in User Administrator Install / assign the DataMonitor license, or grant the user Authorization 7 – Archive export
CSV opens in Excel with one column Field separator collides with decimal separator on locales that use comma Force separator to ; in the export dialog, or change the Windows regional decimal symbol to . for the export user
OLE-DB error "No license for Connectivity Pack" AS-OS Engineering license missing on the WinCC server Install the license via Automation License Manager and restart the WinCC CCAgent service
Runtime reports "Database full" / "Segment error" Hard drive full, or path no longer accessible (UNC share dropped) Check disk space; verify the network path; reconfigure the archive path if the share is permanently unavailable
Unified: compressed logging tag shows "---" Cascading source reference broken after copy / import Open the logging tag, re-select the Source under Compression, recompile and download
Export is empty for a time range Time range falls into a segment that was already swapped out, or the archive was reset Open the Time Range dialog in the editor; confirm the segments exist for the requested window

13. Field-Proven Best Practices

  • Pin your archive path. Always redirect Tag Logging to a dedicated, excluded-from-antivirus volume. Real-time virus scanning of .mdf/.ldf files can stall archive writes and corrupt the transaction log.
  • Configure segmentation. Default behaviour keeps a single growing segment per archive; on long-running projects this produces huge .mdf files. Set a segment size (e.g. weekly or 200 MB) to keep individual files manageable and to make CSV exports bounded.
  • Back up the archive periodically. The ArchiveManager is a live SQL Server. Use the SQL Server Agent job (or a script calling BACKUP DATABASE) to take a daily differential. A copy of the .mdf alone is not a recoverable backup without the .ldf.
  • Standardize the CSV schema. Document the column order and the timestamp format (always use ISO 8601, yyyy-MM-dd HH:mm:ss.fff) in the export script. Consumers (Power BI, Python pandas) parse ISO 8601 without locale settings.
  • Author VBScript exports with a fallback path. If CreateObject("TrendTimeRange") fails on a non-default browser station, the export silently produces an empty file. Wrap the call in On Error Resume Next and write an error line into the CSV.
  • Use the OLE-DB provider for big exports. For ranges longer than 24 h, the OnlineTrendControl export runs out of memory. Stream from the OLE-DB provider with a chunked SELECT TOP n loop instead.
Safety. If Tag Logging is part of a regulated application (pharma, food, energy), the exported CSV is a GxP/regulated record only if produced by a validated export path (OnlineTrendControl right-click or a qualified VBScript) and stored on a write-protected share. The OLE-DB route is for engineering and reporting – not for primary record retention.

14. Quick Reference – File Locations by WinCC Version

Version Default archive path Database engine Interactive CSV export from trend
WinCC V6.0 / V6.0 SP2 <Project>\ArchiveManager\TagLogging(Fast|Slow)\CC_Logging*.mdf MSDE / SQL Server 2000 Not built-in (use DataMonitor or VBScript)
WinCC V6.2 SP2+ Same path; configurable SQL Server 2005 Yes (right-click → Export Data)
WinCC V7.0 / V7.2 / V7.3 / V7.4 / V7.5 Same path; configurable to UNC SQL Server 2008/2012/2014/2016/2019 Yes
WinCC Professional (TIA) Project-relative, configurable SQL Server Express Yes (Trend Control → Export)
WinCC Unified V16 – V20 (TIA) Internal store; not directly browsable SQLite or PostgreSQL (version-dependent) Yes (Unified Trend Control → Export)

15. Verification Checklist

After configuring a CSV export, run this checklist on the operator station:

  1. Trigger the export and confirm the file appears at the configured path.
  2. Open the CSV in Notepad – confirm the expected header and the locale-correct separator.
  3. Open the CSV in Excel – confirm the columns parse into separate cells.
  4. Compare the row count against the SQL source: SELECT COUNT(*) FROM dbo.<ArchiveTable>. They must match within one segment boundary.
  5. Verify the timestamp column is in ISO 8601 form (or matches the documented export format).
  6. If scripted: open the WinCC Global Script diagnostics and confirm no Runtime error line was logged.
  7. On a Unified station: recompile, download, and re-run the export to rule out the broken-cascading-source case.

FAQ

Where does WinCC store tag logging data – is there a .csv file?

No. WinCC stores tag logging in Microsoft SQL Server databases: CC_LoggingFast.mdf / CC_LoggingFast_log.ldf and CC_LoggingSlow.mdf / CC_LoggingSlow_log.ldf. By default they live in <ProjectPath>\ArchiveManager\TagLoggingFast\ and ...\TagLoggingSlow\. CSV must be produced by an explicit export step.

How do I export a WinCC tag archive to CSV from the runtime?

In WinCC V6.2 SP2 and later, right-click inside an OnlineTrendControl in the running picture and choose Export Data → CSV. Set the time range, columns, and field separator (use ; on European locales). The file is written to the path you choose and opened in the default application.

Can I export to CSV from WinCC DataMonitor on V6.0 SP2?

Yes. Install the DataMonitor server component, activate the DataMonitor web page in the project, log in at http://<WinCCServer>/DataMonitor/, open Trends & Alarms → Trends, configure a trend view, and click Export → CSV. A valid DataMonitor license is required on the server.

How can I script a daily CSV export from WinCC Tag Logging?

Configure a picture with an OnlineTrendControl, then write a Global Action in VBScript that calls the control's Export method with a TrendTimeRange object (e.g. last 24 h). Trigger the action from the WinCC scheduler. The runtime writes the CSV to the path passed to Export.

Why does a Unified logging tag show "No valid value" after copying the device?

The TIA Portal V20 documentation notes that cascading logging tags – those with a Source set under Compression – lose their source reference when the device is copied or when tags are imported from a library. Open the logging tag, re-select the source under Compression > Source, recompile, and download to the runtime.

Back to blog