Purging and Resetting Tag Logging Historical Archives in SIMATIC PCS 7 OS
In SIMATIC PCS 7 OS (WinCC), historical Tag Logging trend data is stored in partitioned Microsoft SQL Server database segments (.mdf and .ldf files in the ArchiveManager\TagLoggingFast and TagLoggingSlow directories). Directly deleting these files from Windows Explorer during runtime is strictly prohibited, as it corrupts the SQL Server relational instance (CC_xxxx_R). To safely purge or reset Tag Logging data for an Operator Training System (OTS) or simulator, use the WinCC Explorer 'Archive Configuration -> Reset' function with runtime deactivated, or execute an archive reset script via the WinCC Project Duplicator.
Table of Contents
- Tag Logging Archive Segmentation and SQL Database Architecture
- Why Deleting Archive Files During Runtime Corrupts WinCC
- Supported Methods for Purging Historical Tag Logging Data
- Archive Maintenance and Purge Method Comparison Matrix
- Step-by-Step Procedure to Safely Reset Tag Logging Archives
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Tag Logging Archive Segmentation and SQL Database Architecture
In SIMATIC PCS 7 OS, process measurements (temperatures, pressures, flow rates, levels) are acquired and archived by the WinCC Tag Logging subsystem. Under the hood, Tag Logging stores historical data within a dedicated Microsoft SQL Server database instance named WinCC (CC_<ProjectName>_<Date>_R):
* TagLoggingFast: Archives high-frequency process tags (acquisition cycle $\le 1\text{ minute}$, e.g. every 1 second or 500 ms).
* TagLoggingSlow: Archives low-frequency process tags (acquisition cycle $> 1\text{ minute}$).
Circular Archive Segmentation:
Rather than storing billions of data points in a single giant monolithic file, WinCC partitions data into time-sliced database segments:
* Each segment consists of a pair of files: <Project>_TAG_FAST_<Timestamp_Start>_<Timestamp_End>.mdf (Data file) and .ldf (Transaction Log file).
* These files reside in <OS_Project_Directory>\ArchiveManager\TagLoggingFast\ and ...\TagLoggingSlow\.
* WinCC SQL Server maintains active relational attachments and transaction logs for every active segment file.
Why Deleting Archive Files During Runtime Corrupts WinCC
Commissioning engineers configuring an Operator Training System (OTS) or simulation testbed frequently wish to clear old trend data before beginning a new training simulation run.
A widespread, dangerous error is attempting to delete .mdf and .ldf files directly via Windows Explorer or automated C-scripts while WinCC Runtime is active:
1. Windows File Locking: Active archive segments are held open exclusively by sqlservr.exe. Windows rejects deletion with File In Use / Access Denied.
2. Database Attachment Corruption: If an engineer forces deletion (e.g. via unlock utilities or deleting after abrupt process termination), Microsoft SQL Server retains pointers to the deleted file names in its system catalog.
3. Runtime Crash (CC_xxxx_R Inaccessible): Upon the next archive cycle, WinCC Tag Logging attempts to detach or query the missing segment. The SQL Server instance flags the entire runtime database as 'Suspect' or 'Recovery Pending', causing WinCC graphics to freeze and Tag Logging runtime to crash.
Supported Methods for Purging Historical Tag Logging Data
Siemens supports three clean, safe methodologies for clearing or resetting Tag Logging archives:
Method 1: WinCC Archive Configuration Reset (Recommended)
With WinCC Runtime deactivated, open WinCC Explorer -> Tag Logging. Right-click Archive Configuration -> TagLogging Fast and select Reset. Repeat for TagLogging Slow. This commands the SQL engine to cleanly truncate and detach all historical segment files without damaging database schema.
Method 2: Offline File Purge (Runtime Deactivated)
Deactivate WinCC Runtime and close WinCC Explorer completely. Use Windows Command Prompt or Windows Explorer to navigate to ArchiveManager\TagLoggingFast and TagLoggingSlow and delete all .mdf and .ldf files. When WinCC Runtime re-launches, it detects empty folders and cleanly initializes a fresh, timestamped baseline segment.
Method 3: WinCC Project Duplicator
Use the WinCC Project Duplicator (Save As...) to create a fresh copy of the project. The duplicator automatically copies configuration data, graphics, and scripts while excluding historical Tag Logging runtime databases.
Archive Maintenance and Purge Method Comparison Matrix
The following matrix evaluates methods for resetting Tag Logging historical archives:
Step-by-Step Procedure to Safely Reset Tag Logging Archives
To completely purge Tag Logging historical data for a fresh simulation run:
1. Deactivate WinCC Runtime:
- In WinCC Explorer, click the Deactivate button.
- Wait until WinCC Runtime completely stops and the green runtime indicator extinguishes.
2. Reset Archives in Tag Logging Editor:
- In WinCC Explorer, double-click Tag Logging to open the editor.
- In the navigation tree, expand Archive Configuration.
- Right-click TagLogging Fast and select Reset. Confirm the prompt: Do you really want to reset the archive?.
- Right-click TagLogging Slow and select Reset. Confirm the prompt.
- Close the Tag Logging editor.
3. Alternative Manual Cleanup (If Reset is Inactive):
- Close WinCC Explorer completely.
- Open Windows File Explorer. Navigate to your OS project path:
D:\Projects\<ProjectName>\wincproj\<OS_Name>\ArchiveManager\
- Open the subfolder TagLoggingFast: Select all .mdf and .ldf files and delete them.
- Open the subfolder TagLoggingSlow: Select all .mdf and .ldf files and delete them.
- (Optional): Repeat for AlarmLogging if historical alarms must also be cleared.
4. Restart WinCC and Verify Clean Baseline:
- Open WinCC Explorer and activate WinCC Runtime.
- Confirm that WinCC SQL Server generates a brand-new segment file for the current timestamp.
Verification
Verify that historical data has been purged and new logging is active:
1. Open the WinCC OS process graphics containing trend controls (WinCC OnlineTrendControl).
2. Verify that historical trend curves from prior simulation runs are completely blank.
3. Observe live process tags: Confirm that new data points plot smoothly in real-time.
4. Inspect the filesystem: Open <OS_Project>\ArchiveManager\TagLoggingFast\. Confirm that exactly one new .mdf and .ldf segment file exists and grows steadily in size.
Limitations and Operational Precautions
- Never purge Tag Logging archives on a commercial production plant subject to regulatory compliance (e.g. FDA 21 CFR Part 11 or environmental EPA emissions monitoring); lost historical data cannot be recovered without offline backups.
- Archive resets must be performed independently on both OS Server pairs in a redundant server setup; otherwise, WinCC Redundancy synchronization will copy missing archives from the partner server.
- Always maintain a verified backup of the OS project directory before deleting any database files.
Engineer FAQ
Why did old trend data reappear after I deleted archive files on a redundant OS Server?
In a redundant OS Server pair, the WinCC Redundancy synchronization service (CCRedMon.exe) detects missing archive segments on Server A and automatically copies historical archive files across the network from partner Server B. To clear data, both servers must be purged simultaneously.
Can I delete archive files online using a C-Script in WinCC?
No. Standard Windows file system calls inside C-scripts cannot delete locked SQL database files. To purge data online, you must use the official WinCC Open Development Kit (ODK) API functions to command SQL Server archiving services.
Does clearing Tag Logging data delete tag configurations or trend rulers?
No. Clearing Tag Logging archives only removes historical process sample records. Tag definitions, acquisition cycles, smoothing filters, and graphical trend window configurations are stored in the configuration database and remain completely intact.
Technical References
- SIMATIC PCS 7 OS Process Control System WinCC Manual (A5E39140316)
- SIMATIC WinCC V7.3 System Manual: Archiving Process Values (A5E32315904)
- Siemens Industry Support Portal: Resetting and Managing WinCC Tag Logging Archives
Related Articles
- Purging and Truncating WinCC Alarm Logging Archives in SIMATIC PCS 7
- Configuring Long-Term Process Archiving with SIMATIC Process Historian
- Troubleshooting AS-OS Communication Faults in Virtualized PCS 7 V8.1: ISO vs. TCP/IP Protocols
Related Tags
- SIMATIC PCS 7 V8.1
- WinCC
- Tag Logging
- SQL Server
- ArchiveManager