Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 61883659, Entry date: 05/12/2017

How do you access an SQL database in WinCC Runtime Advanced using a script?

  • Entry
  • Associated product(s)
This FAQ response gives you a sample project with instructions including all the listed examples/topics and the corresponding scripts.

SQL databases are accessed in WinCC Runtime Advanced by means of scripts, except when archiving tags or messages.

To access an SQL database, it must have been created in the SQL server.
The WinCC Runtime Advanced functions as an SQL client.

An SQL database cannot be accessed from a Windows CE-based panel (a Comfort Panel, for example).


  • SQL server1), Microsoft SQL Server 2014, for example
  • SQL data source has been created
  • WinCC Advanced ES or WinCC Professional ES
  • WinCC Runtime Advanced V14 or higher

1) The SQL server used must also be released for the operating systems (that are also released for WinCC Runtime Advanced).

How to create a Microsoft SQL database is described in Entry ID: 61886098.


Documentation (1.1 MB)
The documentation covers the following topics.

  • SQL database
    • Create a database
    • Delete a database
  • Tables
  • Create a table
  • Copy a table
  • Delete a table
  • Read data records from a table
  • Write data records to a table
  • Edit data records in a table
  • Delete data records in a table
  • Read all the data records from a table
Registration required Project (2.0 MB)
This download contains the sample project, which includes all the examples/topics listed, including the relevant scripts.

Runnability and test environment
Below is a list of the components that have been used to create this entry and verify the functions described.

  • PC operating system: Microsoft Windows 7 SP1
  • HMI software: WinCC Advanced V14
  • Operating and monitoring system: WinCC Advanced Runtime V14

Additional Keywords
Databases, Database access, Structured Query Language, SQL, Archiving, Archive

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit