Resolving WinCC Professional Runtime Database Name Changes

David Krause11 min read
SiemensTechnical ReferenceWinCC
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. Overview: The WinCC Professional Runtime Database Renaming Problem

Siemens WinCC Professional (the TIA Portal HMI/SCADA runtime, used with WinCC Runtime Professional V17/V18/V19) generates a new Microsoft SQL Server database every time the project is fully compiled. The database name follows the pattern:

CC_<ComputerName>_<YY_MM_DD_hh_mm_ss>R

For example, a project compiled on a runtime PC named HMI_7HI6 on 14 Oct 2019 at 09:57:05 produces the database CC_HMI_7HI6_19_10_14_09_57_05R. The trailing R distinguishes the runtime database from the configuration database (which carries the same prefix without the R suffix).

This behavior is not a bug. The TIA Portal compiler writes the local timestamp into the database file name so that configuration snapshots remain identifiable, conflict-free, and individually restorable. The side effect, however, is severe for any external tool that needs a stable ODBC/OLE DB connection string:

  • Microsoft Power BI Desktop caches the last connected database name and reconnects to it after restart, producing a credentials prompt against an old, archived database.
  • SQL Server Reporting Services, Tableau, custom .NET/Java reporting services, and Grafana with the MS SQL plugin all hard-code the catalog name in their connection strings.
  • Power Query M-scripts that use Sql.Database("server", "CC_HMI_7HI6_19_10_14_09_57_05R") silently start returning empty result sets after the next compile.

This article catalogs every documented workaround for TIA Portal WinCC Professional V17/V18/V19, the supporting WinCC OLE DB Provider, and the legacy WinCC V7.x CC_ExternalBrowsing database.

2. Root Cause: How the Timestamp Is Embedded

The naming is performed by the TIA Portal compiler service (S7TIA) when the project is re-compiled. Two distinct triggers cause a name change:

  1. Full compile – invoked by "Compile > Software (rebuild all)" or automatically when a referenced PLC tag type changes.
  2. Runtime data regeneration – invoked when the project path or runtime PC name changes, or when archive segments are reconfigured in the HMI tag editor.

A delta transfer (incremental download that retains runtime data) does not regenerate the database name. This is the only officially supported mechanism that holds the name constant across normal engineering change cycles.

TIA Portal Compile DB Name Generator SQL Server Catalog Full Compile New timestamp applied Delta Transfer DB name preserved Runtime path change New timestamp applied

3. Prerequisites and Engineering Tools

Tool / Component Version Tested Required For
TIA Portal V17 / V18 / V19 Project compilation
WinCC Runtime Professional V17 / V18 / V19 Runtime host (Windows 10 LTSC 2019 / Server 2019 / Server 2022)
Microsoft SQL Server 2017 / 2019 / 2022 Standard Stores the runtime database
WinCC OLE DB Provider 1.4.x (bundled with WinCC) External connectivity (provider string WinCCOLEDBProvider.1)
SQL Server Management Studio 19.x Inspecting / mirroring the database
Microsoft Power BI Desktop 2.130 (October 2024) or later Target client (or any ODBC/OLE DB consumer)

The WinCC OLE DB Provider is automatically installed by the WinCC Runtime Professional setup. The data source name visible in the ODBC Data Source Administrator (32-bit and 64-bit) is the one embedded in the catalog name.

4. Workaround 1 — Reading the @DatasourceNameRT System Tag

WinCC Runtime Professional exposes the active runtime data source name through an internal HMI tag named @DatasourceNameRT. The tag is updated by the runtime the moment the SQL catalog becomes available. External clients can subscribe to it via the WinCC OPC DA Server (bundled with the runtime) or via the WinCC OLE DB Provider query language.

4.1 OPC DA Subscription from Power BI or Custom Client

  1. On the runtime PC, open "Start > WinCC > WinCC OPC DA Server" (it registers itself as a DCOM service on port 135 plus dynamic ports).
  2. Add the server OPCServer.WinCC in your client (e.g., the Power BI OPC UA/DA bridge or a C# wrapper using OPCAutomation.dll).
  3. Browse to the tag @DatasourceNameRT. Its quality code is normally Good (192) when the runtime database is reachable.

4.2 Reading via WinCC OLE DB Provider Query

Execute a meta-query against the provider. The catalog name itself is fixed in the connection string, but the database inside it can be enumerated dynamically:

SELECT TOP 1 VariableName, Timestamp, RealValue, QualityCode
FROM <your_runtime_database>.dbo.Archive
WHERE Timestamp BETWEEN '2024-01-01 00:00:00' AND '2024-01-31 23:59:59'
ORDER BY Timestamp DESC

Because @DatasourceNameRT is the actual catalog name, any external script should resolve it before opening the connection. A typical PowerShell implementation looks like:

$opc = New-Object -ComObject OPCAutomation.OPCServer
$opc.Connect("OPCServer.WinCC", "")
$group = $opc.OPCGroups.Add("RTGroup")
$item  = $group.OPCItems.AddItem("@DatasourceNameRT", 1)
$item.Read(2) | Out-Null
$dbName = $item.Value
$conn   = "Provider=WinCCOLEDBProvider.1;Catalog=$dbName;Data Source=WINCCRT\WINCC"
$sql    = "SELECT * FROM dbo.Archive WHERE Timestamp > DATEADD(MINUTE,-10,GETDATE())"
$dt     = New-Object System.Data.DataTable
$adapter= New-Object System.Data.OleDb.OleDbDataAdapter($sql, $conn)
$adapter.Fill($dt)

5. Workaround 2 — Delta Transfer to Preserve the Database Name

A delta download into the runtime writes only the changes since the last transfer and leaves the existing SQL catalog intact. The DB name therefore does not change. To force a delta transfer:

  1. In TIA Portal, mark the WinCC Runtime Professional device in the project tree.
  2. Right-click → "Compile > Software (only changes)" — never "rebuild all".
  3. When the "Load preview" dialog appears, ensure the option "Keep runtime data" is checked. With V18 and later this option is exposed as a checkbox labelled "Retain existing runtime data".
  4. Click "Load". The dialog should report "Number of changed objects: n" rather than "Recompile runtime database".
Critical: If you move the WinCC project to a new folder, rename the runtime PC, or change the SQL Server instance used for archives, the runtime forces a fresh catalog. Treat those events as triggers for a planned full compile and update every external client's connection string at the same time.

6. Workaround 3 — Mirror to a Fixed-Name Database via SQL Server Agent

The most operationally robust pattern is to leave the WinCC-managed database with its generated name, but copy the required archive tables into a second database with a fixed name on a schedule. This is the approach adopted by several power users running WinCC Professional V17/V18 in 24/7 production environments.

6.1 Create the Static Mirror Database

CREATE DATABASE WinCC_Reports;
GO
USE WinCC_Reports;
GO
CREATE SCHEMA archive;

6.2 Dynamic Source Resolution with T-SQL

SQL Server Agent does not natively know the current WinCC runtime catalog name, but you can resolve it by querying sys.databases for the most recent CC_*R entry:

DECLARE @db NVARCHAR(128);
SELECT TOP 1 @db = name
FROM sys.databases
WHERE name LIKE 'CC[_]%[_][0-9][0-9]_[0-9][0-9]_[0-9][0-9]_[0-9][0-9]_[0-9][0-9]_[0-9][0-9]R'
ORDER BY create_date DESC;

DECLARE @sql NVARCHAR(MAX) = N'TRUNCATE TABLE archive.Archive;' +
    N'INSERT INTO archive.Archive SELECT * FROM ' + QUOTENAME(@db) + N'.dbo.Archive' +
    N' WHERE Timestamp > DATEADD(DAY,-1,GETDATE());';
EXEC sp_executesql @sql;

Schedule this job every 5–15 minutes. Power BI then points at a stable catalog WinCC_Reports with a known schema, eliminating the connection-string churn entirely.

6.3 Long-Term Retention Strategy

When WinCC's own archive segment rotates (default segment size is 250 MB, configurable in TIA under "HMI Tags > Archives > Properties"), the segment is moved to the backup folder <ProjectPath>\ArchiveManager\<DBName>\Backup. The mirror job above automatically tracks the new live segment name because it always picks the most recent CC_*R entry.

7. Workaround 4 — Power Query Dynamic Source in Power BI

Power BI Desktop supports a "Dynamic Data Source" parameter. When combined with a small M-script that scans SQL Server system catalogs, the report automatically reconnects to the latest WinCC runtime database on every refresh.

let
    Source = Sql.Databases("WINCCRT\WINCC"),
    WinCC  = Table.SelectRows(Source, each
                  Text.StartsWith([Name], "CC_") and
                  Text.EndsWith([Name], "R")),
    Sorted = Table.Sort(WinCC, {{"CreateDate", Order.Descending}}),
    Latest = Sorted{0}[Name],
    Catalog = Latest,
    Db     = Sql.Database("WINCCRT\WINCC", Catalog),
    Tbl    = Db{[Schema="dbo",Item="Archive"]}[Data]
in Tbl
Warning: Power BI caches resolved connection metadata in the .pbix file. The first refresh after a WinCC full compile will show a privacy-fence warning until you set the data source privacy level to "Organizational" in File > Options > Privacy.

For the official Microsoft reference on dynamic data sources, see Manage data source privacy levels in Power Query and Power BI data source prerequisites.

8. WinCC V7.x Alternative — The CC_ExternalBrowsing Database

Legacy WinCC V7.x does not have a fixed-name runtime catalog either, but it offers a separate database named CC_ExternalBrowsing that does keep its name across project changes. This database is created only when one of the following options is installed:

  • WinCC/DataMonitor — for web-based reporting and dashboards.
  • WinCC/Connectivity Pack — for OPC UA Historical Access and SQL forwarding.
  • WinCC/IndustrialDataBridge — for arbitrary external archive targets.

The CC_ExternalBrowsing database does not contain the live archive segments. It only contains segments that have been rotated out of the runtime and are referenced by the Archive Connector service. To populate it with historical data you must configure Archive Backup and the Archive Connector (see the WinCC V7.5 SP2 documentation at the Siemens Industry Online Support portal, search term "Archive Connector").

Property WinCC V7.x CC_ExternalBrowsing WinCC Professional Runtime
Database name Fixed (CC_ExternalBrowsing) Timestamped (CC_HMI_xx_yy_mm_dd_hh_mm_ssR)
Live archive data No (backup-restored only) Yes
Required licence option Connectivity Pack / DataMonitor None (standard runtime)
Provider WinCC OLE DB Provider WinCC OLE DB Provider
Query language SQL with tag-name filters SQL with tag-name filters

9. WinCC OLE DB Provider — Connection String Reference

Every workaround above eventually opens an OLE DB connection. The canonical connection string for the WinCC OLE DB Provider is:

Provider=WinCCOLEDBProvider.1;
Catalog=<@DatasourceNameRT>;
Data Source=<ServerName>\WINCC;
User Id=<user>;
Password=<pwd>;
Mode=Read;
Parameter Description Example
Provider OLE DB driver WinCCOLEDBProvider.1
Catalog SQL database name (use @DatasourceNameRT) CC_HMI_7HI6_19_10_14_09_57_05R
Data Source SQL Server\Instance WINCCRT\WINCC
Mode Read or ReadWrite Read
User Id / Password SQL auth or Windows auth (omit for Trusted_Connection) sa / ********

For SQL Server authentication, the provider accepts either explicit credentials or the keyword Trusted_Connection=Yes. The provider is registered under the ProgID WinCCOLEDBProvider.1 and is available in 32-bit and 64-bit variants; 64-bit clients must use the 64-bit provider.

10. Verification Checklist

Run this checklist after every workaround implementation, and re-run it whenever a TIA Portal service pack is applied:

  1. Open SQL Server Management Studio on the runtime PC and confirm SELECT name FROM sys.databases WHERE name LIKE 'CC_%R' returns exactly one row whose suffix matches _YY_MM_DD_hh_mm_ssR.
  2. Verify that the WinCC Runtime Manager shows status "Running" and the HMI tag table browser reports a quality of "Good" for @DatasourceNameRT.
  3. From a remote workstation, open Power BI Desktop, click "Get Data > SQL Server", enter the dynamic M-script from §7, and confirm that the navigation pane lists the archive table.
  4. If you implemented the SQL Agent mirror (§6), check the job history — last run should have succeeded and SELECT COUNT(*) FROM WinCC_Reports.archive.Archive should grow monotonically.
  5. If you implemented the OPC DA bridge (§4.1), validate with an OPC client (e.g., Matrikon OPC Explorer) that the tag @DatasourceNameRT returns the current catalog name and updates within 5 s of a forced full compile.
  6. Force a full recompile in TIA Portal ("Compile > Software (rebuild all)"), then re-run steps 2–5. Your external clients must reconnect without manual intervention.

11. Troubleshooting Matrix

Symptom Likely Cause Corrective Action
Power BI shows "Cannot connect to the database" after WinCC full compile Cached connection string points to old catalog Use dynamic M-script (§7) or schedule a refresh on WinCC compile event
@DatasourceNameRT returns empty string Runtime not yet started or archive DB not initialised Wait for "Runtime started" event; check that at least one archive is configured
SQL Agent job fails with "Invalid object name 'dbo.Archive'" Mirror job ran before WinCC archive was created Add retry logic (WAITFOR / TRY-CATCH) and delay job by 60 s after service start
CC_ExternalBrowsing not visible in SSMS Connectivity Pack / DataMonitor not licensed Install option or fall back to SQL Agent mirror (§6)
Delta transfer silently performs full recompile Runtime path or PC name was changed Avoid renaming the runtime PC; deploy projects to a stable path
OLE DB Provider returns "Class not registered" on 64-bit client Using 32-bit provider from 64-bit Power BI Install WinCC Runtime 64-bit components or use Power BI 32-bit

12. Frequently Asked Questions

Can I give the WinCC Professional runtime database a fixed name?

No. The timestamped catalog name is generated by the TIA Portal compiler and is not user-configurable. The only officially supported way to preserve the name is to perform delta transfers only and never change the runtime PC name or project path.

What is the @DatasourceNameRT tag and where do I find it?

It is an internal WinCC HMI tag created automatically by the runtime. It holds the current SQL catalog name (for example CC_HMI_7HI6_19_10_14_09_57_05R) and can be read through the OPC DA Server or through a script. Use it to build dynamic connection strings in any external client.

Does WinCC V7.x have a fixed-name database I can query from Power BI?

Yes — CC_ExternalBrowsing — but only if a WinCC option such as DataMonitor, Connectivity Pack, or IndustrialDataBridge is installed and the Archive Connector is configured. The database only contains restored backup segments, not live archives.

Why does my Power BI report stop refreshing after a TIA Portal project edit?

Power BI caches the catalog name in the .pbix file. A full recompile generates a new CC_*R catalog, so the cached name no longer exists. Either switch to the dynamic M-script in §7 or replicate the data into a fixed-name database with a SQL Server Agent job.

Which WinCC OLE DB Provider build supports the timestamped catalog?

The WinCC OLE DB Provider shipped with WinCC Runtime Professional V17, V18, and V19 (builds 17.0.0.x through 19.0.0.x) supports both the timestamped catalog and the legacy CC_ExternalBrowsing pattern. The ProgID is always WinCCOLEDBProvider.1 regardless of build.

Back to blog