Resolving Process Historian 2014 SP2 Update 2 Database Schema Upgrade Failures (Return Code 1)
In SIMATIC Process Historian (PH) 2014, when upgrading from SP2 to SP2 Update 2 results in the automated database maintenance wizard failing during script execution 'Update_To_14022.bat with return code 1' and halting with 'Database update failed', the error is caused by SQL Server table locking, insufficient transaction log space in tempdb, or an inactive SQL Server Agent service. The patch script attempts to alter partitioned schema tables while background connections or maintenance jobs hold exclusive table locks. To resolve this error, engineers must review 'UpdateDatabaseErrors.log', ensure the SQL Server Agent service is running, terminate orphaned database connections, and execute the failed schema update script manually using sqlcmd under administrative privileges.
Table of Contents
- Process Historian Database Migration Architecture (Version 14020 to 14022)
- Root Causes of Update_To_14022.bat Script Failures
- Analyzing UpdateDatabaseErrors.log and SQL Exception Codes
- Step-by-Step Procedure: Repairing and Finalizing Database Updates
- Diagnostic Matrix for Process Historian Database Migration Scripts
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Process Historian Database Migration Architecture (Version 14020 to 14022)
SIMATIC Process Historian 2014 operates on a dedicated Microsoft SQL Server instance (HISTORIAN). Long-term process telemetry, alarm journals, and batch records are stored within dynamically partitioned SQL tables (HistorianStorage, HistorianCommon).
When installing cumulative software updates (such as PH 2014 SP2 Update 2):
- The installer deploys patched service binaries and replaces database scripts in C:\Program Files\Siemens\ProcessHistorian\Setup\Database\.
- Upon system reboot, the Process Historian Database Update Wizard launches automatically.
- The wizard executes incremental Transact-SQL migration batch scripts sequentially:
- Update_To_14021.bat: Upgrades schema from version 14020 to 14021.
- Update_To_14022.bat: Upgrades schema from version 14021 to 14022.
- Each script must return exit code 0. If any SQL statement encounters a deadlock, schema constraint violation, or memory allocation failure, the batch script aborts with return code 1, leaving the database in an inconsistent maintenance state.
Root Causes of Update_To_14022.bat Script Failures
Diagnostic analysis of return code 1 reveals three primary failure modes:
- Active Database Connections and Table Locks:
- The scriptUpdate_To_14022.batapplies structural modifications (e.g., adding indices, altering column widths) to high-volume time-series partition tables.
- If local monitoring tools, SQL Server Management Studio (SSMS), or lingering background services (HistorianStorage,HistorianReporting) hold active connections, the schema alteration encounters a lock timeout. - SQL Server Agent Service Stopped:
- Several migration routines register scheduled partition compression tasks with SQL Server Agent (HISTORIAN). If this service is disabled or stopped, the batch script fails when calling agent stored procedures. - Transaction Log or TempDB Exhaustion:
- Migrating multi-gigabyte historical databases requires extensive sorting intempdb. If the hard drive hostingtempdblacks sufficient free disk space (minimum 20 GB recommended), the SQL transaction aborts with error9002(The transaction log is full).
Analyzing UpdateDatabaseErrors.log and SQL Exception Codes
The exact Transact-SQL error is recorded in the installation log directory:
C:\ProgramData\Siemens\Logs\UpdateDatabaseErrors.log
(or UpdateDatabase.log).
Common SQL exception signatures:
- Msg 1205, Level 13 (Deadlock Victim): Two update transactions competed for partition locks.
- Msg 5069, Level 16 (ALTER TABLE statement failed): Table locked by an active SPID.
- Msg 1101 / 1105 (Could not allocate space in database): Disk volume full during index rebuild.
Step-by-Step Procedure: Repairing and Finalizing Database Updates
Follow this procedure to resolve the script failure and complete the database upgrade:
Step 1: Prepare the SQL Server Environment
- Open Windows Services (
services.msc). - Verify that SQL Server (HISTORIAN) is running.
- Verify that SQL Server Agent (HISTORIAN) is started and set to Automatic startup.
- Stop all Process Historian application services:
CCCAPHServer,HistorianStorage, andHistorianReporting.
Step 2: Terminate Active Connections
- Launch SQL Server Management Studio (SSMS) as Administrator and connect to
.\HISTORIAN. - Open a New Query window and execute the following command to place the database in single-user mode:
sql USE master; ALTER DATABASE HistorianStorage SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE HistorianStorage SET MULTI_USER; - Close SSMS to release all query window handles.
Step 3: Execute the Failed Migration Script Manually
- Open an Administrative Command Prompt (
cmd.exe). - Navigate to the database script directory:
cd "C:\Program Files\Siemens\ProcessHistorian\Setup\Database\" - Execute the failed script manually to observe detailed console feedback:
Update_To_14022.bat - The batch script connects via
sqlcmd, executes the schema migration, updates the version table to14022, and exits with return code0.
Step 4: Restart the Process Historian Services
- Once the script finishes cleanly, reboot the Process Historian server.
- Open the Process Historian Management Console; confirm that the database version displays
14022and the operating state indicates 'Active'.
Diagnostic Matrix for Process Historian Database Migration Scripts
The table below outlines common migration script aborts:
HistorianStorage; set single-user and re-runtempdb or log drive exhausted; expand disk spaceVerification
To confirm that the Process Historian database update is complete:
1. Database Version Audit: In SQL Server Management Studio, execute:
SELECT CurrentVersion FROM HistorianCommon.dbo.VersionTable;
Confirm that the returned version integer is 14022.
2. Management Console Status: Open PH Management Console; verify that server state displays 'Active' with steady green indicator.
3. Data Ingestion Check: Confirm that telemetry packets received from WinCC OS servers are actively being committed into SQL table partitions without error logs.
Limitations and Operational Precautions
Engineering teams must observe the following precautions:
- Always create a complete SQL database backup (HistorianStorage and HistorianCommon) before initiating any Process Historian service pack or cumulative update installation.
- Never terminate a running SQL database migration script via Task Manager; interrupting schema modification mid-transaction can corrupt database metadata.
- Always validate final license quantities and MLFBs against the applicable Siemens catalog and authorized distributor quotation when ordering Process Historian packages.
Engineer FAQ
Where can I find the master installation logs for Process Historian?
Process Historian logs all setup and database migration transactions under C:\ProgramData\Siemens\Logs\ and C:\ProgramData\Siemens\ProcessHistorian\LogFiles\.
Can I roll back to SP1 if the SP2 Update 2 database update fails?
Rollback requires uninstalling the update and restoring the full SQL Server database backup taken prior to starting the SP2 upgrade; Transact-SQL schema changes cannot be uninstalled automatically.
Does Process Historian SP2 Update 2 require updating WinCC PH-Ready?
Yes. When applying Update 2 to the Process Historian server, Siemens strongly recommends updating the PH-Ready component on all connected OS servers to the matching update level.
Technical References
- SIMATIC Process Historian 2014 SP2 Administration Guide (A5E36987735)
- Microsoft SQL Server Troubleshooting: Error 1205 Deadlocks and Index Alteration
- Siemens Support: Upgrading Process Historian Database Schemas (Entry ID: 109740190)
Related Articles
- Troubleshooting Cyclic Connection Drops Between Redundant OS Servers and Process Historian 2014 SP2
- Troubleshooting Process Historian 2014 Connection Failures and Empty WinCC Archiving Graphs
- Customizing Alarm and Archive Report Templates in SIMATIC Information Server 2014 SP2
Related Tags
- Process Historian
- PH 2014 SP2
- Database Update
- SQL Server
- Update_To_14022.bat