MS SQL in Siemens WinCC: Database Setup and Configuration

David Krause11 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

Overview: Role of Microsoft SQL Server in WinCC

Siemens SIMATIC WinCC uses Microsoft SQL Server as its persistent storage engine for project configuration, runtime data, and process/historical archives. The relationship has been in place since WinCC V6.0, and every subsequent major release (V6.2, V6.4, V7.0, V7.2, V7.3, V7.4, V7.5, and the TIA Portal WinCC Comfort/Advanced/Professional families) continues to rely on SQL Server as the database engine that backs the WinCC project.

SQL Server is therefore not an optional add-on that can be removed: the WinCC Explorer, the Graphics Designer, the Tag Logging and Alarm Logging runtimes, the User Archive component, and the WinCC/WebUX and WinCC/DataMonitor options all require a working SQL Server instance. Removing or corrupting the SQL Server instance effectively disables the WinCC project.

Warning: Do not manually edit, drop, or detach the WinCC databases through SQL Server Management Studio while a WinCC runtime is active. The WinCC Runtime writes continuously to the archive segment databases; terminating or truncating them mid-run produces corrupted segments and undefined tag logging behavior. Use a dedicated virtual machine or a separate engineering PC for any experimentation with raw T-SQL.

WinCC Database Architecture

WinCC uses three logical families of SQL databases, each with a distinct lifecycle and ownership. Understanding which database does what is the first step toward safe configuration, backup, and reporting.

Database Family Default Name Pattern Purpose Created By
Configuration database CC_<ProjectName>_<Date>_<Time> (project) and CC_<ComputerName>_<Date>_<Time> (computer) Stores the offline project: tags, alarm classes, picture structure, user archive definitions, schedules, scripts, connection lists. WinCC Explorer on first save / project migration
Runtime database Runtime_<ComputerName> plus per-archive sub-databases Manages the open archive segments, segment rotation, swap-out behavior, license counts, and the user archive runtime tables. WinCC Runtime on first activation
Archive segment databases TLG_F<taglogging>, ALG_F<alarmlogging>, UA_F<userarchive> Hold the actual process value messages and alarm events in time-stamped tables; rotated on segment change (size, time, or external trigger). Tag Logging / Alarm Logging / User Archive at runtime

All three families are stored as SQL Server databases. By default WinCC installs a local instance of SQL Server, historically named WINCC for SQL Server 2005/2008/2012, then WINCC2014 for the SQL Server 2014 bundle shipped with WinCC V7.4, and then WINCC2016 for the SQL Server 2016 bundle used in WinCC V7.5. The instance name appears in SQL Server Configuration Manager under SQL Server Services.

Supported SQL Server Versions per WinCC Release

WinCC Version Supported SQL Server Bundled Instance Notes
WinCC V7.0 / V7.2 SQL Server 2008 R2 / 2012 WINCC 32-bit only on legacy installations
WinCC V7.3 SQL Server 2012 SP1/SP2 WINCC Redistributed via WinCC setup
WinCC V7.4 SQL Server 2014 SP1/SP2 WINCC2014 WinCC setup installs the instance automatically
WinCC V7.5 / V7.5 SP1 SQL Server 2016 SP2 / 2017 WINCC2016 AlwaysOn AG not supported as WinCC backend
TIA WinCC Professional V16/V17 SQL Server 2016 / 2019 Bundled installer Shared instance on engineering PC
TIA WinCC Professional V18/V19 SQL Server 2019 / 2022 Bundled installer Verify compatibility list before upgrading

For evaluation and development, Microsoft offers SQL Server 2025 Developer and Evaluation editions as a free download with full Enterprise feature set, restricted to non-production use. See the official SQL Server product page and the SQL Server downloads hub for current builds. Always cross-check the version you intend to install against the WinCC compatibility list published in the Siemens Industry Online Support portal before commissioning.

Field-proven caveat: A WinCC installation that has been upgraded to a Windows version with a newer SQL Server native client but still uses an older WinCC instance is a common source of ODBC Error 80004005 and SQL Server does not exist or access denied messages. Pin the WinCC instance to its own SQL Server version.

Prerequisites

  1. Operating system. WinCC V7.5 supports Windows 10 (64-bit, Pro/Enterprise) and Windows Server 2016/2019/2022. TIA WinCC Professional V18+ requires Windows 10/11 64-bit or Windows Server 2019/2022.
  2. User account. The Windows user running the WinCC services (CCAgent, CCProjectMgr, CCArchiveConn, CCLicenseServer) must be a member of the local SIMATIC HMI user group and must have db_owner rights on every WinCC database. Default install grants these via the WinCC setup.
  3. SQL Server account mode. Use Windows Authentication only. SQL Server mixed-mode (with the sa account) is not required and is discouraged for production.
  4. Disk and I/O. Place the SQL data files (.mdf) and log files (.ldf) on a volume with low-latency storage. Tag Logging archives with high acquisition rates (sub-second, 100 ms, 500 ms) can grow by gigabytes per shift.
  5. Service account. The SQL Server (WINCC2016) service must run as LocalSystem or a dedicated domain account with the Perform volume maintenance tasks and Lock pages in memory privileges.

Step-by-Step: First-Time WinCC and SQL Server Configuration

  1. Run the WinCC setup with administrative rights. Launch Setup.exe from the WinCC installation media. The setup detects whether SQL Server is present and, if not, installs the appropriate bundled instance (WINCC2014, WINCC2016, or the TIA-bundled equivalent). Do not install a separate, user-supplied SQL Server side-by-side before WinCC; the WinCC setup expects to manage the instance itself.
  2. Confirm the SQL Server service. Open SQL Server Configuration Manager and verify that SQL Server (WINCC2016) (or the version-appropriate name) is Running and set to Automatic startup.
  3. Verify TCP/IP and Named Pipes. In SQL Server Network Configuration → Protocols for WINCC2016, enable TCP/IP and Named Pipes. Leave the default port (1433) untouched unless a port conflict is identified. Restart the service after a change.
  4. Open WinCC Explorer and create a project. Right-click the project, choose Project Properties, and confirm the Database server field shows the local instance. For distributed systems with a separate archive server, enter the archive server's instance name here.
  5. Configure the Tag Logging and Alarm Logging paths. In Tag Logging → Archives → [your archive] → Properties → Archive Configuration, set the Storage path. The path is a Windows directory where the SQL Server database files (TLG_F*.mdf) and segment backups reside. Typical default: C:\ProgramData\Siemens\Automation\WinCC\Archives\<ServerName>\TagLogging.
  6. Define segment change criteria. Use Size (for example 256 MB), Time (for example daily at 00:00), or Event-controlled (e.g. batch end). When a segment change fires, the active .mdf is detached, copied to the storage path, and a fresh database is attached.
  7. Activate the project. On activation, the WinCC Runtime creates the runtime database Runtime_<ComputerName> and the first archive segment databases. Monitor WinCC Explorer → Tools → Status of Tag Logging / Alarm Logging for healthy green indicators.
  8. Test connectivity. From an engineering station, open SQL Server Management Studio and connect to \\<WinCCServer>\WINCC2016 with Windows Authentication. The databases CC_<ProjectName>_* and TLG_F* should be visible. Do not edit them.

External Access: Reading WinCC Data from Outside WinCC

Reading the archive data without affecting the runtime is a frequent requirement for OEE dashboards, MES handshakes, and ad-hoc reporting. Three supported approaches exist.

  1. WinCC DataMonitor / WinCC OLE DB. The recommended path. WinCC DataMonitor exposes tag logging and alarm logging data through a web-based dashboard and a SQL-like query interface. For programmatic access, the WinCC/Connectivity Pack and WinCC OLE DB Provider provide a read-only OLE DB interface. Sample VBScript from inside WinCC:
Dim conn, rs
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "WinCCOLEDBProvider.1"
conn.Properties("Data Source").Value = ".\WINCC2016"
conn.Properties("Catalog").Value = "CC_Project_2024_10_01_10_30_00"
conn.Open
Set rs = conn.Execute("SELECT * FROM Archive\TagLogging\MyArchive WHERE Timestamp > '2024-10-01'")
While Not rs.EOF
    Debug.Print rs.Fields("Value").Value
    rs.MoveNext
Wend
rs.Close
conn.Close
  1. SQL Server native connection (read-only, with care). The archive segment databases are normal SQL Server databases, so any ODBC, JDBC, or ADO.NET client can read them. Use a dedicated read-only SQL login mapped to db_datareader on the TLG_F* and ALG_F* databases. Avoid opening a long-running transaction; WinCC needs the database to be available for the next segment change.
  2. User Archive via ODBC. The WinCC User Archive component can be exposed as an ODBC data source for MES handshakes. Configure the source in ODBC Data Sources (64-bit) → System DSN; the driver ships with the SIMATIC WinCC Connectivity Pack.
Important: Never grant db_owner or db_ddladmin to an external reporting user. A dropped table inside an open archive segment database forces a full re-archive from WinCC project properties and can lose historical data.

Backup and Recovery Strategy

SQL Server databases cannot be safely backed up by simply copying the .mdf and .ldf files while the SQL Server service is running. Use one of the following.

Method Scope Tool Frequency Recommendation
Detach and copy Offline copy of a single database SQL Server Management Studio (right-click → Tasks → Detach) Only during planned maintenance windows
SQL Server native backup Full, differential, transaction log BACKUP DATABASE CC_Project_2024_10_01 TO DISK = 'D:\Backup\...bak' Daily full + hourly transaction log for archive DBs
WinCC segment backup Closed archive segments WinCC Explorer → Tag Logging → Archive Backup Per segment change

The WinCC Archive Backup action is the most operationally important: it copies closed archive segment databases from the live storage path to a backup path where they can be stored on a network share or moved to a long-term retention volume. Schedule it as a post-segment-change job triggered by a Windows scheduled task or by a script called from the WinCC scheduler.

Best Practices

  • One SQL instance per WinCC project family. Avoid mixing a WinCC V7.4 (WINCC2014) and a WinCC V7.5 (WINCC2016) project on the same server unless both are explicitly listed as supported. Different SQL Server versions target different model databases and compatibility levels, and cross-version attach/detach can corrupt segments.
  • Disable sa and set
    CHECK_POLICY = ON
    for every SQL login, even if Windows Authentication is used exclusively.
  • Set the SQL Server max server memory to roughly 75% of physical RAM on archive servers, leaving room for the OS, WinCC runtime, and OPC UA stack. Example on a 32 GB host: sp_configure 'max server memory', 24576; RECONFIGURE;
  • Schedule UPDATE STATISTICS on the tag logging segment databases weekly to keep query plans realistic after heavy data growth.
  • Pre-size the TLG_F* databases. Right-click the database → Properties → Files → set the initial size to a realistic estimate (for example 5 GB) so SQL Server does not have to auto-grow during a high-frequency process event.
  • Keep tempdb on a fast volume and split it across multiple data files (one per logical processor up to eight).
  • Avoid anti-virus scans on the archive directory and the SQL Server data directory. Add the paths to the AV exclusion list.

Troubleshooting Common SQL Errors in WinCC

Symptom Typical Cause Corrective Action
WinCC Explorer shows Database server not found on startup SQL Server (WINCC2016) service stopped or disabled Set service to Automatic in SQL Server Configuration Manager and start it
Activation fails with ODBC Error 80004005 Mismatched SQL Server version or broken named-pipes protocol Confirm version, enable Named Pipes and TCP/IP, restart service
Tag Logging shows Segment change failed Storage path on disk full or read-only Free space on archive volume; verify write permission of the WinCC user
SQL Server will not start, error 9003 Corrupt master database after power loss Restore from master backup; rebuild master as last resort, then restore msdb and model
Database stuck in Recovery Pending Disk I/O error or detached during write Run ALTER DATABASE [name] SET EMERGENCY; DBCC CHECKDB (name, REPAIR_ALLOW_DATA_LOSS) with WinCC stopped
Performance drops after weeks of runtime Auto-growth on tempdb and large fragmented indexes Pre-size, rebuild indexes on archive databases off-hours

Verification Checklist

  1. WinCC Explorer opens the project without a database error dialog.
  2. SELECT @@VERSION executed from a read-only login returns the expected SQL Server build.
  3. Activating runtime shows green indicators under Status of Tag Logging and Status of Alarm Logging.
  4. Forcing a segment change (set size to 1 MB) creates a fresh TLG_F*.mdf and copies the closed segment to the storage path within a few seconds.
  5. A read-only ODBC client returns rows from the closed segment without locking the database.
  6. A full BACKUP DATABASE completes and the .bak file is restorable on a test SQL Server.

FAQ

Which SQL Server version is bundled with WinCC V7.5?

WinCC V7.5 ships with Microsoft SQL Server 2016 SP2, installed as instance WINCC2016. WinCC V7.4 uses SQL Server 2014 as instance WINCC2014. Mixing instances from different WinCC major versions on one server is not supported.

Can I install my own SQL Server before installing WinCC?

No. The WinCC setup expects to install and configure the matching SQL Server instance itself. A pre-existing user-supplied SQL Server typically causes setup to skip the WinCC instance creation, which then fails when WinCC tries to attach the configuration database to a non-existent WINCC2016 instance.

How do I read tag logging data from an external MES without affecting runtime?

Use the WinCC OLE DB Provider or the WinCC Connectivity Pack for read-only access; both are designed not to interfere with the running segments. If you connect through native SQL Server, create a dedicated SQL login with db_datareader only and never run long-lived transactions against the live segment databases.

Why are my archive segments failing to swap?

Three causes are responsible in roughly 90% of field cases: the archive volume is full, the Windows user running the WinCC services lacks write permission on the storage path, or the SQL Server service is stopped. Check the Windows event log (Application source MSSQLSERVER) and the WinCC diagnostic files in C:\ProgramData\Siemens\Automation\Logfiles\.

Is it safe to run a SQL Server 2022 instance side-by-side with the WinCC 2016 instance?

Yes, side-by-side installations of different SQL Server major versions on the same host are supported by Microsoft, but you must keep the WinCC project bound to WINCC2016 in Project Properties. For learning and T-SQL experimentation, use SQL Server 2025 Developer Edition (free for non-production) on a virtual machine isolated from any live WinCC runtime.

Back to blog