Resolving The SQL Server Cannot Access Data Errors During PCS 7 WinCC OS Downloads

Resolving The SQL Server Cannot Access Data Errors During PCS 7 WinCC OS Downloads

The error 'The SQL server cannot access data' during an OS project download from a SIMATIC PCS 7 Engineering Station (ES) to an OS Server or Client occurs when the target machine's Microsoft SQL Server instance (WinCC) retains locked database handles, when WinCC background runtime services are hung, or when Windows user accounts lack membership in the SIMATIC HMI local group. To resolve this, run the Reset_WinCC.vbs utility located in C:\Program Files (x86)\Siemens\WinCC\bin\ on the target station to release locked database files and terminate background tasks. Verify that identical Windows user credentials exist on both ES and OS machines with membership in SIMATIC HMI and Administrators groups, reboot the target station, and re-execute the download.

Table of Contents

Executive Summary

During commissioning and software maintenance in SIMATIC PCS 7, downloading updated operator station projects from the Engineering Station (ES) to distributed OS Servers or OS Clients is a daily workflow. A critical failure occurs when the transfer abruptly halts, displaying the modal error: 'The SQL server cannot access data' or 'Database could not be attached/opened'. This condition arises because WinCC relies on an embedded Microsoft SQL Server instance (WINCC) to host project configuration and runtime archives. If the target station's runtime was not cleanly deactivated, if background tasks (CCWriteArchive.exe, CCProjectMgr.exe) remain hung, or if Windows user access permissions are misconfigured, SQL Server prevents the incoming project database files from overwriting the target directory.

Architecture and Fundamental Mechanics

The mechanics of an OS download involve complex database detaching, network file copying, and re-attaching sequences:

1. The WinCC OS Download Sequence

When an engineer initiates a project download in SIMATIC Manager (PLC -> Download -> OS):
1. SIMATIC Manager instructs the target OS station via SIMATIC Shell and RPC to close WinCC Explorer and detach the active project database (<Project>.mdf / <Project>.ldf).
2. The target SQL Server instance disconnects from the database files.
3. The ES copies updated .mdf, .ldf, graphics (*.pdl), and C/VBS scripts across the Windows network share.
4. The target SQL Server re-attaches the database files and registers the project with the local WinCC service manager.

2. Failure Modes and Root Causes

  • Orphaned File Locks: If WinCC Runtime on the target station crashed or was terminated abruptly, the SQL Server service (sqlservr.exe) retains exclusive open file handles on the .mdf database files. When the ES attempts to overwrite these files, Windows returns an access violation error.
  • Windows User Group Privileges: The transferring user account on the ES must be recognized by the target machine. Both PCs must share identical user accounts and passwords, and the account must be explicitly added to the local Windows groups SIMATIC HMI, SIMATIC NET, and Administrators.
  • Network Share Rights: The target destination directory must be shared with full read/write permissions granted to the SIMATIC HMI group.

Step-by-Step Implementation Procedure

To resolve the locked SQL Server database error and complete the OS download successfully:

Step 1: Execute Reset_WinCC.vbs on the Target Station

  1. On the target OS Server or Client station, log in as Administrator.
  2. Ensure WinCC Runtime and WinCC Explorer are closed.
  3. Open Windows Command Prompt as Administrator or navigate in Windows Explorer to:
    C:\Program Files (x86)\Siemens\WinCC\bin\
  4. Double-click Reset_WinCC.vbs (or run cscript Reset_WinCC.vbs from the command line).
  5. Wait for the script to finish terminating all lingering WinCC processes (CCProjectMgr, CCWriteArchive, ALM, etc.) and detaching databases.
  6. Reboot the target PC to ensure a completely clean operating system state.

Step 2: Verify Windows Local User Group Memberships

  1. Open Computer Management (compmgmt.msc) on both the ES and the target OS.
  2. Navigate to Local Users and Groups -> Groups.
  3. Verify that the logged-in user account belongs to:
    - SIMATIC HMI
    - SIMATIC NET
    - Administrators
  4. Ensure passwords for this account are identical on both workstations.

Step 3: Inspect Network Share Permissions on Target Directory

  1. On the target OS, locate the shared project folder.
  2. Right-click the folder -> Properties -> Sharing tab -> Advanced Sharing.
  3. Under Permissions, verify that SIMATIC HMI has Full Control.
  4. Under the Security tab (NTFS permissions), confirm that SIMATIC HMI has Full Control.

Step 4: Re-execute OS Download from ES

  1. In SIMATIC Manager on the ES, right-click the OS station object.
  2. Select PLC -> Download.
  3. Choose Entire project (Full download) to overwrite any fragmented project files.
  4. Confirm that the download completes with status 'Download completed successfully'.

Verification

Confirm proper download and database attachment:

  1. Project Opening Test:
    - On the target OS, launch WinCC Explorer and open the newly downloaded project.
    - Confirm the project opens cleanly without SQL attachment errors.

  2. Runtime Activation Test:
    - Click the Activate button in WinCC Explorer.
    - Confirm that WinCC Runtime initializes, connecting to process tags and historical archives smoothly.

  3. SQL Server Log Inspection:
    - Check SQL Server logs in C:\Program Files\Microsoft SQL Server\MSSQL...\MSSQL\Log\ERRORLOG to verify that database attach commands executed with return code 0.

Limitations and Operational Precautions

Operational limitations and precautions:

  1. Never Run Reset_WinCC on a Redundant Partner in Runtime: Executing Reset_WinCC.vbs unconditionally kills all WinCC services. In an operating plant, ensure the redundant partner is actively carrying the process before resetting.
  2. Manual File Deletion Warning: Never manually delete .mdf or .ldf files while SQL Server is running, as this corrupts the master database catalog (master.mdf).
  3. Domain vs Workgroup Constraints: In workgroup configurations, mismatched Windows passwords between ES and OS will trigger silent authentication failures that manifest as SQL access errors.
  4. Commercial Disclaimer: Verify all software versions, system expansions, and engineering licenses with an authorized Siemens distributor or the Siemens Industry Mall.

Engineer FAQ

What does Reset_WinCC.vbs do?

It is a Siemens utility that gracefully stops all running WinCC background services, terminates orphan processes, and detaches active project databases from SQL Server.

Why must the Windows user belong to the SIMATIC HMI group?

Siemens configures Microsoft SQL Server instance permissions specifically for the SIMATIC HMI Windows group. Users outside this group cannot attach or modify WinCC project databases.

Can I download an OS project while WinCC Runtime is active on the target station?

Changes-only downloads can be performed during runtime if configured, but an Entire Project download requires WinCC Runtime to be deactivated.

Where can I find Reset_WinCC.vbs?

It is located in the standard WinCC installation directory at C:\Program Files (x86)\Siemens\WinCC\bin\Reset_WinCC.vbs.

What should be done if the download fails even after running Reset_WinCC?

Reboot the target workstation, check network share permissions for SIMATIC HMI, and verify that the target hard drive has adequate free disk space.

Technical References

Related Articles

Related Tags

  • WinCC Download
  • SQL Server
  • Reset_WinCC
  • SIMATIC HMI
  • Database Attachment
20 respuestas