WinCC Tag Logging: Exporting Tag Archives to CSV Files

David Krause19 min read
SCADA ConfigurationSiemensTutorial / How-to
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

1. Problem Overview: Bulk Export of WinCC Tag Logging Archives

WinCC tag logging archives are typically used for on-screen trends, tables, and alarm correlation rather than for direct external consumption. As soon as a downstream system, historian, or audit process requires the raw archive in a portable, human-readable format, the built-in runtime views are no longer sufficient and an explicit CSV export workflow must be engineered.

The common industrial case is the one shown by the field report: roughly 1,000 internal tags sampled at 2-second intervals (later grouped into 2- to 3-second logical groupings for performance), producing one comma-separated file per day. The export must run unattended, must include all configured tags in a single batch, and must preserve a high-resolution timestamp for analytics.

Siemens WinCC V7.x and V8.x provide three realistic paths to solve this:

  1. Runtime Table Control or Trend Control export triggered by an operator or by a WinCC global script.
  2. Connectivity Pack (OLE DB / ODBC) read access to the SQL Server-backed tag log database, executed from any external client or from a WinCC global script.
  3. Open Development Kit (ODK) direct C/C++ API access to the WinCC archive system, suitable for high-throughput and embedded workflows.

This article walks through the prerequisites, the SQL schema, the export scripts, the millisecond timestamp issue, the data-rate sizing for 1,000 tags, and the unattended scheduling that closes the loop on a daily CSV file.

Scope note. The procedures below target SIMATIC WinCC V7.4 SP1, V7.5, and WinCC V8.0 / V8.1. Older V6.x tag logging databases use the legacy DBF/CTG format and require an additional migration step on top of the routines described here.

2. WinCC Tag Logging Data Architecture

Before designing an export, you must understand where the data physically lives. WinCC stores tag logging values inside a Microsoft SQL Server database (system database CC_<ComputerName>_<RuntimeID>_<Date>) created by the WinCC project. The relevant tables are:

Table / View Contains Used For
dbo.Archive One row per configured tag log (process, compressed, etc.) Discovering archive IDs
dbo.ArchiveTag Tag → archive mapping, data type, sign Column-to-tag resolution
dbo.ArchiveData_<ID> Time-stamped values per archive segment Source of CSV rows
dbo.PDLRTData_<ID> Runtime data swap segment Live in-memory rows
dbo.MsSegment_<ID> Millisecond-resolution values Sub-second samples

Process-value archives are split automatically into segments of a configurable size (default 1 day or 1,000,000 values, whichever is reached first). When a day rolls over, WinCC creates a new ArchiveData_<ID> table with a new segment identifier. The export routine must therefore follow the segment pointer rather than hard-coding a table name.

The WinCC documentation set on the Siemens Industry Online Support portal describes the schema in detail under the entry for SIMATIC WinCC V8.0 Information System, section "Tag Logging - Database Structure":

3. Prerequisites and Licensing

  1. WinCC Runtime with a valid license for the tag logging system. Each logging tag consumes one "Tag Logging" license point.
  2. WinCC Connectivity Pack license for OLE DB/ODBC read access. The Connectivity Pack option is required to expose the archive database to external tools via WINCCOLEDB or WinCC_RT_<ComputerName> as a registered OLE DB provider. Without it, the SQL path fails with provider-not-registered errors.
  3. SQL Server (Express, Standard, or higher). WinCC V8.x supports SQL Server 2017, 2019, and 2022. Ensure the WinCC database instance is configured for SQL authentication or that the local service account is granted read access.
  4. ODK (Open Development Kit) for the C-API path. The ODK is licensed separately and provides the headers, libraries, and runtime DLLs under %ProgramFiles%\Siemens\Automation\WinCC\WebNavigator\ODK\include on the engineering station. Project redistribution requires the ODK runtime on the target computer.
  5. Filesystem permission for the export target directory. WinCC Runtime runs under the CC_OpmRun account; the export directory must be writable by this account (or by the configured user account, if WinCC is running as a service user).
  6. Disk space sized for the worst-case daily payload (calculation in section 9).

4. Method 1 - Runtime Table Control and Trend Control CSV Export

The simplest path is the operator-facing export that is built into the WinCC WinCC Online Table Control and Online Trend Control. It is a good fit for ad-hoc or end-of-shift dumps. The export is configured in Graphics Designer under the control's properties:

  1. Open the picture with the Online Table Control.
  2. In the configuration dialog, switch to Columns and add every tag you want to expose. For 1,000 tags, build 1,000 columns with appropriate Time Column and Value Column entries. Use the column Time Format field to set yyyy-MM-dd HH:mm:ss.fff for millisecond precision.
  3. Switch to the Toolbar page of the dialog. Enable the Export Data button so operators (or scripts) can trigger the export.
  4. Set Export Data → File Name to a fixed path, e.g. D:\TagExports\ArchiveExport_<yyyy-MM-dd>.csv. WinCC substitutes runtime variables such as @CurrentTime@ and @UserName@.
  5. Set Export Data → Separator to ; if the target is a German-locale Excel, or to , for the standard RFC 4180 format. Enable Quote All for tags whose values may contain commas.
  6. Set Export Data → Export Type to CSV. The available types are CSV, XML, and ODIF; the CSV type is the portable output for downstream tooling.

To trigger the export from a global VBScript, call the internal function HMIRuntime.Trace in combination with the control's export button hotkey, or use the documented ODK method on the control:

' VBScript - Trigger export on Online Table Control named "tblTagLogging"
Dim sFile
sFile = "D:\TagExports\ArchiveExport_" & Replace(Date, "/", "-") & ".csv"
HMIRuntime.Screens("MainOverview").ScreenItems("tblTagLogging").ExportData(sFile)

The ExportData method executes the same code path as the toolbar button. It blocks the calling thread until the file is written, so for 1,000 columns expect several seconds. Drive it from a delayed Plan action (see section 7) to avoid freezing the runtime.

Performance limit. The Table Control export loads the entire visible time range into memory, then serializes it. With 1,000 columns and a 24-hour window, the working set reaches several gigabytes. Use the Connectivity Pack path (section 5) when the on-screen control method times out or OOMs.

5. Method 2 - Connectivity Pack SQL-Based Bulk Export

The Connectivity Pack exposes the WinCC archive database as an OLE DB provider named WINCCOLEDB. Any client able to speak OLE DB (ADO, ODBC bridge, ADO.NET) can query tag log data without going through the WinCC runtime. The provider is documented in the SIMATIC WinCC V8.0 Connectivity Pack manual.

5.1 Provider connection string

Provider=WINCCOLEDBProvider.1;
Catalog=CC_Engineering_22_07_18_15_30_22R;
Data Source=.\WinCC

The Catalog parameter must be the live runtime database name visible under SQL Server Management Studio → Databases on the WinCC server. The Data Source is the SQL Server instance configured for the WinCC project (default .\WinCC for V7.5 and later, may be a named instance for older releases).

5.2 Discovering the archive ID for a given tag

SELECT [ArchiveID], [TagName], [DataType], [Cycle]
FROM   dbo.ArchiveTag
WHERE  [TagName] = 'MOTOR_SPEED_PV'

The ArchiveID returned is the suffix appended to ArchiveData_. If the project has multiple archives, the same tag may appear in several rows; choose the one whose Cycle matches the polling rate (2,000 ms in the case described).

5.3 Extracting all values for a 24-hour window

DECLARE @archive INT = 5;        -- set to your ArchiveID
DECLARE @from   DATETIME = '2024-05-12 00:00:00';
DECLARE @to     DATETIME = '2024-05-13 00:00:00';

SELECT
    T.[TimeStamp],
    T.[ValueFloat]  AS [MOTOR_SPEED_PV],
    T.[Quality],
    T.[Flags]
FROM   dbo.ArchiveData_5 AS T WITH (NOLOCK)
WHERE  T.[TimeStamp] >= @from
  AND  T.[TimeStamp] <  @to
ORDER  BY T.[TimeStamp] ASC;

For a single archive, the script above produces one column per tag. For 1,000 tags across 1,000 archives, the export is implemented as a dynamic PIVOT or as a row-by-row UNION ALL of per-tag queries - the latter is faster on large SQL Express installations because it avoids the optimizer's misestimate on the pivot.

5.4 Bulk CSV writer in PowerShell

# Export-WinCCArchive.ps1
[CmdletBinding()]
param(
    [string]$OutDir   = 'D:\TagExports',
    [string]$Date     = (Get-Date -Format 'yyyy-MM-dd')
)

$connStr = 'Provider=WINCCOLEDBProvider.1;' +
           'Catalog=CC_Engineering_22_07_18_15_30_22R;' +
           'Data Source=.\WinCC'

$conn = New-Object System.Data.OleDb.OleDbConnection($connStr)
$conn.Open()

$tags = @('MOTOR_SPEED_PV','MOTOR_TORQUE_PV','VALVE_01_POS')
$hdr  = 'Timestamp,' + ($tags -join ',')

$outFile = Join-Path $OutDir ("ArchiveExport_$Date.csv")
[IO.File]::WriteAllText($outFile, $hdr + "`r`n", [Text.Encoding]::UTF8)

$from = "{0:yyyy-MM-dd} 00:00:00" -f (Get-Date $Date)
$to   = "{0:yyyy-MM-dd} 00:00:00" -f (Get-Date $Date).AddDays(1)

foreach ($t in $tags) {
    $sql = "SELECT [TimeStamp], [ValueFloat] FROM dbo.ArchiveData_5 " +
           "WHERE [TimeStamp] >= '$from' AND [TimeStamp] < '$to' " +
           "ORDER BY [TimeStamp] ASC"
    $cmd  = New-Object System.Data.OleDb.OleDbCommand($sql, $conn)
    $rdr  = $cmd.ExecuteReader()
    $rows = @()
    while ($rdr.Read()) {
        $rows += ('{0:yyyy-MM-dd HH:mm:ss.fff},{1}' -f $rdr[0], $rdr[1])
    }
    $rdr.Close()
    Add-Content -Path $outFile -Value $rows -Encoding UTF8
}
$conn.Close()

For the 1,000-tag case, parallelize the per-tag queries using PowerShell ForEach-Object -Parallel (PowerShell 7+) or a System.Threading.Tasks.Dataflow pipeline, each worker pinned to one of the SQL Express worker threads (4 on Express, 12 on Standard). The CSV is then merged in timestamp order during a final pass.

Connectivity Pack runtime requirement. The OLE DB provider only answers when WinCC Runtime is active. Stopping the WinCC service or running the script during project loading returns "Provider cannot open: E_CCS_NOT_CONNECTED". Schedule the script to start at least 60 seconds after WinCC enters "Running" state.

6. Method 3 - ODK C/C++ Application Export

The ODK is the only path that talks to WinCC's in-memory archive cache without going through OLE DB. It is the right answer for high-throughput, multi-thousand-tag scenarios and for embedded ODK applications that ship with the WinCC runtime. The full C-API is documented in:

6.1 Skeleton C++ exporter

// OdkTagExport.cpp - compile against ODK headers
#include "apdefap.h"
#include "dmclient.h"
#include "lslapi.h"

int main(int argc, char* argv[])
{
    if (LSLGetActiveRunTime() == 0) {
        printf("WinCC Runtime not running.\n");
        return 1;
    }

    DM_VAR_SOURCE src = DM_VAR_SOURCE_LSL;
    DM_VAR_FILTER flt = { 0 };
    long lArchiveId = 5;            // ArchiveID from dbo.ArchiveTag
    DM_OPEN_OPTIONS opt = { 0 };
    opt.bAsync       = FALSE;
    opt.lpfnCallback = NULL;

    long hConn = DMOpenConnectionEx("MyApp", &opt);
    if (hConn < 0) { printf("OpenConn failed: %ld\n", hConn); return 1; }

    // Read raw rows from the archive
    long hTag = DMGetArchive(lArchiveId, NULL, NULL, NULL);
    long hQuery = DMStartTagQuery(hConn, hTag, 0,
                                  "2024-05-12 00:00:00.000",
                                  "2024-05-13 00:00:00.000");
    if (hQuery < 0) { printf("Query failed: %ld\n", hQuery); return 1; }

    FILE* fp = fopen("D:\\TagExports\\ArchiveExport_2024-05-12.csv", "w");
    fprintf(fp, "Timestamp,Value,Quality\n");

    DM_VAR_DATA row;
    while (DMGetNextTagValue(hQuery, &row) == DM_OK) {
        SYSTEMTIME st;
        FileTimeToSystemTime(&row.ftTimeStamp, &st);
        fprintf(fp, "%04d-%02d-%02d %02d:%02d:%02d.%03d,%.4f,%lu\n",
                st.wYear, st.wMonth, st.wDay,
                st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
                row.dValue, row.dwQuality);
    }
    fclose(fp);

    DMStopTagQuery(hQuery);
    DMCloseConnection(hConn);
    return 0;
}

The ODK approach bypasses the SQL Server entirely, so it keeps working when the SQL service is busy. It also gives true sub-millisecond precision because it reads the in-memory LSL cache directly. Downside: it ships native code that must be installed alongside the WinCC runtime and must be recompiled when the WinCC version changes.

6.2 Calling the ODK from a WinCC global C script

If you have an existing C-script in the WinCC project, the same calls are valid - just call DMGetArchive with the archive ID resolved through the DMFindTag helper. This is the path the source project mentioned when it first tried "a C script and the help from ODK".

7. VBScript Automation Inside WinCC

For a fully integrated solution that runs without an external scheduler, drive the export from a WinCC Global Script - Plan or a Scheduled Action on a picture. The plan fires on a configurable interval, runs on the WinCC background thread, and can call any of the methods above.

' Module: TagExport_Plan.vbs - call from a daily Plan at 23:59:55
Sub OnPlanStart()
    Dim sPath, oFSO, oFile, oTag, dt, dtFrom, dtTo, sFileName

    sPath     = "D:\TagExports\"
    Set oFSO  = CreateObject("Scripting.FileSystemObject")

    If Not oFSO.FolderExists(sPath) Then oFSO.CreateFolder sPath

    dt    = DateAdd("d", -1, Now)              ' export yesterday's data
    dtFrom = Year(dt) & "-" & Right("0" & Month(dt),2) & "-" & Right("0" & Day(dt),2) & " 00:00:00"
    dtTo   = Year(dt) & "-" & Right("0" & Month(dt),2) & "-" & Right("0" & Day(dt),2) & " 23:59:59"

    sFileName = sPath & "ArchiveExport_" & FormatDateTime(dt, vbShortDate) & ".csv"

    ' Use HMIRuntime to drive a hidden Online Table Control on the overview
    HMIRuntime.Screens("Overview").ScreenItems("tblTagLogging").
        ExportData sFileName

    ' Notify the operator via the alarm log
    HMIRuntime.Trace "TagExport: written " & sFileName
End Sub

When the picture is not currently open, HMIRuntime.Screens("Overview") still returns a valid handle; WinCC loads the picture on demand. Confirm that the picture is in the "Start Picture" list or that its parent is opened in a layered window so the export control is instantiated.

8. Millisecond Timestamp Handling in CSV Output

A common follow-up observed in the field report was: "Why are milliseconds not shown in the CSV file?". The root cause is that the Online Table Control's Time Column is formatted using the regional setting, which defaults to seconds-only unless overridden.

Apply all three of the following:

  1. Open the column configuration of the Time Column. Set Time Format to a custom string yyyy-MM-dd HH:mm:ss.fff. The fff is case-sensitive and the lowercase fff produces three-digit milliseconds; ffffff produces microseconds if the underlying archive supports them.
  2. On the WinCC server, set the operating-system Regional Settings → Short Date to yyyy-MM-dd and the Time format to HH:mm:ss.fff. Alternatively, call the WinCC internal function SetLanguage(0) with a custom format string in the project startup.
  3. When writing CSV from your own script, format the timestamp explicitly: FormatDateTime(Now, vbShortDate) & " " & Format(Now, "HH:mm:ss.fff"). Do not rely on the default string conversion of Date, which truncates to whole seconds on most locales.

If the underlying archive is a process value archive with the "Use millisecond resolution" property enabled in WinCC Tag Logging Configuration, the values are written into dbo.MsSegment_<ID> instead of the regular segment table. Your export query must therefore union both tables:

SELECT [TimeStamp], [ValueFloat]
FROM   dbo.ArchiveData_5
UNION ALL
SELECT [TimeStamp], [ValueFloat]
FROM   dbo.MsSegment_5
ORDER  BY [TimeStamp] ASC;

9. Performance Sizing - 1,000 Tags at 2-Second Sampling

A 1,000-tag, 2-second process archive is non-trivial. Use the following sizing equations to plan disk, RAM, and CSV write bandwidth before commissioning.

Quantity Equation Value for 1,000 tags @ 2 s
Samples per minute per tag 60 / cycle_s 30
Samples per minute total tag_count × 30 30,000
Samples per day total tag_count × 86,400 / cycle_s 43,200,000
Bytes per record (raw SQL) 8 ts + 8 val + 4 q + 4 flags + overhead ~36 bytes
Raw SQL size per day samples × 36 ~1.55 GB
Bytes per CSV line "yyyy-MM-dd HH:mm:ss.fff",value,quality ~45 bytes
CSV size per day 1,000 × samples_per_tag × 45 ~1.94 GB
Compressed (7z/gzip) CSV size × 0.10 typical ~200 MB

Implications for the engineering team:

  • Disk: allocate at least 10 GB per day of raw archive before compression, or 2 GB after CSV + 7z, for a one-week retention. A 1 TB SSD is the practical minimum for 365-day retention.
  • SQL Server: SQL Server Express is hard-limited to 10 GB per database. At 1.55 GB/day, the archive fills Express in roughly 6 days. Either switch to SQL Server Standard (no 10 GB cap) or enable WinCC's "Database segments, switch after 1,000,000 values" property to keep each ArchiveData_N table below the limit. The ODK path bypasses the SQL Server altogether and is the safest sizing answer.
  • RAM: the OLE DB provider loads result pages into the consuming process. Allocate 4 GB to the export process and stream with a cursor or read uncommitted hint.
  • Write bandwidth: writing 1.94 GB to a magnetic disk takes 30-60 seconds; to an SSD it takes under 10 seconds. Schedule the export at 23:59:30 to keep the file from overlapping with the next day's segment rollover.

10. Daily File Automation with Windows Task Scheduler

The export script must fire on a wall-clock schedule independent of the WinCC project. The cleanest way is to register it in Windows Task Scheduler as a daily task with the following properties:

  1. Open Task Scheduler → Create Task (not Create Basic Task). Switch the user to CC_OpmRun or the configured WinCC service user, and tick Run whether user is logged on or not.
  2. On the Triggers tab, set Daily at 23:59:30 and enable Synchronize across time zones only if the plant straddles daylight-savings changes.
  3. On the Actions tab, start a program. For PowerShell: powershell.exe -NoProfile -ExecutionPolicy Bypass -File D:\Scripts\Export-WinCCArchive.ps1. For the C/C++ exporter: "D:\Tools\OdkTagExport.exe" --date %date:~-4%-%date:~3,2%-%date:~0,2%.
  4. On the Conditions tab, uncheck Start the task only if the computer is on AC power and check Wake the computer to run this task if the WinCC server is normally sleeping (industrial PCs typically are not).
  5. On the Settings tab, set If the task fails, restart every = 5 minutes, up to 3 times. The restart catches the case where WinCC has not yet reached "Running" state at the trigger time.

Pair the schedule with a wrapper .bat file that emits a marker line on every run, so a missing file is easy to spot from the next morning:

@echo off
set LOG=D:\TagExports\_ExportLog.txt
echo [%date% %time%] starting daily export >> "%LOG%"
powershell -NoProfile -ExecutionPolicy Bypass -File D:\Scripts\Export-WinCCArchive.ps1
if %ERRORLEVEL% NEQ 0 (
    echo [%date% %time%] FAILED code=%ERRORLEVEL% >> "%LOG%"
    exit /b %ERRORLEVEL%
)
echo [%date% %time%] OK >> "%LOG%"

11. Verification and Validation Procedure

After the first three days of production, run the following validation pass to confirm the export is sound:

  1. Row count check. Sum the CSV line count of the produced file. It should equal 1,000 tags × 43,200 samples ≈ 43,200,000 ÷ 1,000 (since rows are wide, one timestamp per row × 1,000 columns) = 43,200 lines. Tighter check: compare against the SQL row count of SELECT COUNT(*) FROM dbo.ArchiveData_5 WHERE [TimeStamp] > '...'; the two numbers must match within 0.1 %.
  2. First / last timestamp. Open the CSV. The first row should be YYYY-MM-DD 00:00:00.000 ± 5 seconds; the last row should be YYYY-MM-DD 23:59:58.000 ± 5 seconds. Drift beyond 10 seconds indicates a missed cycle in the WinCC tag logging configuration.
  3. Gap audit. Load the file into pandas and run df['Timestamp'].diff().dt.total_seconds().value_counts().head(). The dominant delta must be 2.0 (or 2.5 / 3.0 if the source project grouped tags). Any other delta is a logging interruption.
  4. Quality / flags column. Every row should have quality = 0xC0 (good) for the production windows. A 0x00 row corresponds to a PLC connection loss and should be cross-referenced with the WinCC alarm log for the same time.
  5. File hash and size. Run certutil -hashfile D:\TagExports\ArchiveExport_2024-05-12.csv SHA256 on both the export server and the downstream historian. Equal hashes confirm the file was not corrupted on transfer.

12. Troubleshooting Matrix

Symptom Likely Cause Resolution
CSV file empty (0 bytes) WinCC runtime not in Running state when the export script ran Add 60 s delay to the scheduled task; verify with HMIRuntime.Trace "WinCC ready" at start-up
E_CCS_NOT_CONNECTED from OLE DB Connectivity Pack not licensed, or the OLE DB provider is unregistered Run regsvr32 "%ProgramFiles%\Siemens\Automation\WinCC\bin\WinCCOLEDBProvider.dll" as admin
Milliseconds missing from CSV Column time format not overridden; regional setting is seconds Set Time Column → Time Format to yyyy-MM-dd HH:mm:ss.fff; for ms archives also union MsSegment_N
SQL Server Express 10 GB error Archive database grew past the Express cap Switch to Standard; or reduce segment size to 500,000 values; or use the ODK path
Export runs 2-3 minutes per day Query returning millions of rows; single-threaded reader Add WITH (NOLOCK); parallelize per-tag in PowerShell 7; pre-aggregate before writing CSV
One column only has NaN Tag spelling mismatch between ArchiveTag and the project Validate with SELECT TagName FROM dbo.ArchiveTag ORDER BY TagName
File locked, cannot overwrite Excel or another tool still has yesterday's file open Append a microsecond suffix to the file name, or close the tool before triggering
Export fired but log says "Access denied" Export directory writable only by the operator, not the service account Grant Modify on D:\TagExports to CC_OpmRun
Trend control export only saves XML, not CSV Default export type is XML in some installs Set Export Data → Export Type = CSV in the property dialog
Time column shows localized month name ("Mai" / "Mayo") Regional setting on the runtime server differs from the export server Force ISO format on the time column; do not rely on the OS locale

13. Recommended Architecture for 1,000-Tag / 2-Second Dumps

For the architecture described in the field report, the following combination has the lowest implementation risk and the highest throughput:

  1. ODK C++ exporter on the WinCC server, running as a Windows service or as a daily triggered command. Reads from the in-memory LSL cache; does not touch SQL Server.
  2. PowerShell wrapper (section 5.4) used as a fallback when the ODK build is not yet available on a particular WinCC version. The wrapper writes one CSV per archive and merges them in timestamp order using a streaming System.IO.FileStream appender.
  3. Windows Task Scheduler triggering both at 23:59:30, with 5-minute restart on failure.
  4. WinCC internal Plan in addition, as a redundant trigger. If the scheduled task is missed, the Plan writes a daily file at 00:00:05 and tags it with the previous date.

Confirm the millisecond override on every Time Column, validate the first three days of dumps with the procedure in section 11, and document the procedure in the project's Operating Manual so the change-control owner can re-validate after any tag list update.

How do I export a WinCC tag logging archive to CSV in a single batch without listing every tag in the script?

Query the dbo.Archive and dbo.ArchiveTag tables via the WINCCOLEDB provider to enumerate all configured tags, then issue one SELECT per archive (e.g. SELECT * FROM dbo.ArchiveData_N) for the time window of interest, and concatenate the results. The ODK path (DMStartTagQuery / DMGetNextTagValue) iterates tags in C++ and is the most direct way to dump a full archive without scripting each tag by name.

Why are the milliseconds missing in my exported CSV?

The Time Column in the Online Table Control uses the regional setting, which defaults to seconds. Override the Time Format property to the literal string yyyy-MM-dd HH:mm:ss.fff. If you also have millisecond-resolution archives, union dbo.ArchiveData_N with dbo.MsSegment_N because the millisecond rows are written to a separate segment table.

What license do I need to read WinCC tag logging from an external tool?

You need the WinCC Connectivity Pack license, which exposes the WINCCOLEDB OLE DB provider. Without it, ODBC/OLE DB clients receive E_CCS_NOT_CONNECTED. For the C-API path (ODK), the ODK runtime must be installed on the target computer, and the ODK developer license must be present on the engineering station that builds the application.

How large will the daily CSV be for 1,000 tags sampled at 2 seconds?

Approximately 1.94 GB of raw CSV (≈ 43,200 rows × 1,000 columns × ~45 bytes per CSV line), compressible to roughly 200 MB with 7z. The underlying SQL Server database grows by approximately 1.55 GB per day. Plan disk and SQL Server edition (Standard, not Express) accordingly.

Can the export run unattended at 23:59 every day?

Yes. Register a Windows Task Scheduler task that runs under the WinCC service user (typically CC_OpmRun), set the trigger to Daily at 23:59:30, allow the task to wake the computer, and configure a 5-minute restart on failure to cover the case where WinCC has not yet reached Running state. Add a WinCC Plan action as a redundant trigger at 00:00:05 to catch any missed runs.

Back to blog