WinCC Adv Archive SQL Database en
WinCC Adv Archive SQL Database en
WinCC Adv Archive SQL Database en
Security Siemens provides products and solutions with industrial security functions that support the
Informati secure operation of plants, systems, machines and networks.
on In order to protect plants, systems, machines and networks against cyber threats, it is
necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial
security concept. Siemens’ products and solutions only form one element of such a
concept.
Customers are responsible to prevent unauthorized access to their plants, systems,
machines and networks. Systems, machines and components should only be connected
to the enterprise network or the internet if and to the extent necessary and with
appropriate security measures (e.g. use of firewalls and network segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be taken into
account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more
secure. Siemens strongly recommends to apply product updates as soon as available and
to always use the latest product versions. Use of product versions that are no longer
supported, and failure to apply latest updates may increase the customer’s exposure to
cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security
RSS Feed under http://www.siemens.com/industrialsecurity.
Siemens AG 2018 All rights reserved
Contents
1 Introduction ........................................................................................................ 3
1.1 Configuration Notes .............................................................................. 4
1.2 Components Used ................................................................................ 4
2 Configuration 1: Access to the SQL Server .................................................... 5
2.1 Configure an SQL Database ................................................................ 5
2.2 Configure the Data Source (ODBC) ..................................................... 8
3 Configuration 2: Access to the SQL Server .................................................. 13
3.1 Configure an SQL Database .............................................................. 13
3.2 SQL Database User Data Management ............................................ 14
3.2.1 General Information............................................................................ 14
3.2.2 Authentication via the Windows Login ............................................... 15
3.3 Windows Firewall Settings ................................................................. 18
3.4 Configure (Remote) the Data Source (ODBC) ................................... 21
4 Read Out/Display the SQL Database Table................................................... 22
5 WinCC (TIA Portal) ........................................................................................... 25
5.1 Archive Configuration ......................................................................... 25
5.2 Operation of the Sample Application .................................................. 26
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 2
1 Introduction
1 Introduction
The entry describes how to use WinCC Runtime Advanced V15 and
Microsoft SQL Server 2014 to archive tags and messages in a
Microsoft SQL database.
Two configurations are described.
PC-Station 1
Siemens AG 2018 All rights reserved
PC-Station2
RT Advanced
PC-Station1
MS SQL-Database
Remote
PC-Station „n+1“
RT Advanced
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 3
1 Introduction
Note When "SQL database" is mentioned in the entry, this always refers to the
Microsoft SQL Database.
The Microsoft SQL Database is a component of the
Microsoft SQL Server 2014.
Note There are numerous parameters and possible settings in an SQL database. The
entry can only deal with the settings required for this example.
Siemens AG 2018 All rights reserved
Note The "Microsoft SQL Server Management Studio 17" tool is not included in the
WinCC (TIA Portal) delivery package. You can download the tool via the
Microsoft Support pages (https://support.microsoft.com).
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 4
2 Configuration 1: Access to the SQL Server
Via the drop-down list box you select the server on which the data is to be
stored (1).
If multiple servers are installed on the PC, then in the drop-down list box you
select the menu "<Browse for more…>".
Under "Database Engine" you select the following server
"Computer Name\WINCCPLUSMIG2014". The server you specify here is
also used for configuring the data source (ODBC) (link).
Click the "Connect" button.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 5
2 Configuration 1: Access to the SQL Server
No. Description
The green arrow icon (1) indicates that the server connection is active.
Now you can access databases already created and have the values displayed
(2).
Siemens AG 2018 All rights reserved
How to have values displayed in the SQL database is described below (chapter
4, "Read Out/Display the SQL Database Table").
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 6
2 Configuration 1: Access to the SQL Server
Table 2-2
No. Description
1. First you execute Steps 1 to 3 in the "Establish a server connection" section,
Table 2-1.
2. Create a new database
Note:
In the course of the exercise the tags and messages will be archived in this
database.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 7
2 Configuration 1: Access to the SQL Server
The menu for configuring the ODBC Data Source opens (1). 1
Siemens AG 2018 All rights reserved
In the menu bar you select the "User DSN" tab (1).
Click the "Add..." button (2).
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 8
2 Configuration 1: Access to the SQL Server
No. Description
3. Select the driver "SQL Server" (1).
Click "Finish".
4. Name (1):
– Here you enter the name that you have stored in the PC Runtime
configuration in the archives under "Properties > General > Storage
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 9
2 Configuration 1: Access to the SQL Server
No. Description
5. "Windows NT authentication" (1) is used in this example. If you select "SQL
Server authentication" (2), you can specify the required Login ID and
Password in the bottom part of the window (3). You must have stored the
data previously under "Security" in the SQL database.
Enable the "Connect to..." check box (4).
Click the "Next >" button.
When you click the "Next >" button, the data source attempts to establish a
connection to the SQL server. If this does not work, you get an error message.
In this case you should check:
– That the SQL server has started.
– The server name.
– The security settings of the SQL database.
– The user rights of the SQL database.
4
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 10
2 Configuration 1: Access to the SQL Server
No. Description
6. When the SQL server connection has been established, the following window is
displayed.
Enable the "Change the default database to:" option (1).
Via the drop-down list box you select the database to be referred to (2).
See the entries here that you stored when creating the SQL server
connection. In this case "Machine03" (link).
The values of the WinCC Runtime Advanced are archived in this SQL
database.
In the screen you enable the two options displayed (3).
Click the "Next >" button.
1
2
3
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 11
2 Configuration 1: Access to the SQL Server
No. Description
8. You then get a summary of the settings that have been made. You can test the
connection via the "Test Data Source…" button.
Close the configuration via the "OK" button.
"Database_ArchiveMessage".
Via the "Configure…" button you can call and change the settings that have been
made (1).
For this you first mark the name of the user data source.
This completes the settings for the data source (ODBC). Close the menu with the
"OK" button.
Now you can start the WinCC Runtime Advanced. Information about configuring
the WinCC Runtime Advanced is available in chapter 5, WinCC (TIA Portal).
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 12
3 Configuration 2: Access to the SQL Server
Other settings
In the Properties of the SQL server check that the "Allow remote connections
to this server" option is enabled.
– Right-click the SQL server and open the Properties. A window opens.
– Under "Select a page" you mark the item "Connections" (1).
In the "Remote server connections" section you enable the "Allow remote
connections to this server" option (2).
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 13
3 Configuration 2: Access to the SQL Server
In the later configuration of the data source (ODBC) you can choose whether the
SQL server authentication is to be made
Via the Windows login (1) or
Via the user administration of the SQL server (2).
The FAQ response describes the "Windows authentication".
Figure 3-1
1
2
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 14
3 Configuration 2: Access to the SQL Server
Table 3-2
No. Description
1. PC Station1, create Windows user
In the "PC Station1" you create a Windows user. The user must have the same
name and password as the user on the "PC Station2" on which the WinCC
Runtime Advanced is running.
In this example:
User: hh => Nickname, (…User1)
Password: 100
Note:
The user must not be assigned to any special group.
(Create new user under Windows 10).
Siemens AG 2018 All rights reserved
You do not have to be logged in on the PC Station1 with the new "User1" in order
to operate the SQL database.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 15
3 Configuration 2: Access to the SQL Server
No. Description
3. PC Station1, SQL database, assign Windows user
1
4 3
2
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 16
3 Configuration 2: Access to the SQL Server
No. Description
5. "User Mapping" page
Here you define the database which the user "hh" is permitted to access.
The final assignment is made in the settings of the data source ODBC (link).
Select the "Server Roles" page (1).
1
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 17
3 Configuration 2: Access to the SQL Server
1 2
Siemens AG 2018 All rights reserved
You have to add a firewall rule to ensure that the incoming connection of the "PC
Station2" is not blocked by the Windows Firewall of the "PC Station1". No rule is
required if the Windows Firewall is turned off.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 18
3 Configuration 2: Access to the SQL Server
No. Description
3.
In this window you click "New Rule…" (2).
The "New Inbound Rule Wizard" window opens. The program file of the SQL
server is called via the wizard.
This measure ensures that incoming queries to the SQL server are no longer
blocked by the Windows Firewall.
In the first screen you select the "Program" radio button (1).
Then click the "Next >" button.
In the second screen you select the "This program path:" radio button and
then click "Browse..." (2).
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 19
3 Configuration 2: Access to the SQL Server
No. Description
5. Navigate to and mark the program file "sqlservr.exe". Make sure that you
select the correct file for the SQL database being used. This is particularly
important if there are different versions of the SQL server installed on the
same PC (see information under "Tip").
Click the "Open" button.
Then click the "Next >" button.
Tip:
Use the Windows Search function to make a prior search for the word
"sqlserver.exe" on drive "C".
If you have installed multiple SQL servers, then make sure you use the file
corresponding to the SQL server being used.
Siemens AG 2018 All rights reserved
6. In the following screens the displayed default settings have been used.
In the last screen you specify a name and close the wizard via the "Finish"
button.
This completes the settings for the Windows Firewall.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 20
3 Configuration 2: Access to the SQL Server
Note If you cannot establish a connection to the remote server, this might be due to
the firewall of the operating system. For testing or during commissioning you can
try to turn off the firewall where the SQL database is installed. Bear in mind in
this case that you might run the risk of allowing access to unauthorized users.
Table 3-4
No. Description
1. The configuration corresponds to the settings in section 2.2 "Configure the Data
Source (ODBC) ".
Siemens AG 2018 All rights reserved
For the menu item "Server" you now do not select the local server but the server
to which you want to have remote access and on which the SQL database is
installed.
Server:
– Via the drop-down list box you select the remote server that you selected
when creating the database server connection. In this case "PC
Station1\WINCCPLUSMIG2014" (link).
Click the "Next >" button.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 21
4 Read Out/Display the SQL Database Table
Table 4-1
No. Description
1. First perform the steps 1 to 3 as in section 2.1 "Configure an SQL Database".
Select the database whose values you want to have displayed and open the
folder tree.
Open the "Tables" file folder.
The archive files are displayed in the folder.
=> dbo.Archivename
Note:
The "0" in the file name is generated by the system.
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 22
4 Read Out/Display the SQL Database Table
No. Description
2. Right-click the archive file.
Navigate to the menu item shown in the screen.
Siemens AG 2018 All rights reserved
3. When you enable the "New Query Editor Windows" function the script shown in
the screen is generated automatically. The script includes the function that reads
out the values of the selected archive file.
Click "Execute" (1) in the toolbar.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 23
4 Read Out/Display the SQL Database Table
No. Description
4. The figure shows the table with the values read out of the archive file after running
the "Execute" function.
To update the table you click the "Execute" function (1) again in the toolbar.
1
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 24
5 WinCC (TIA Portal)
You define the storage location in the menu "Properties > General". Select
the "Database" menu from the drop-down list box (1).
Enter the name of the data source (2).
This name is used to address the ODBC database with the archived tag
names (link).
Siemens AG 2018 All rights reserved
3. This completes the Special Settings for archiving in the SQL database.
If you are using other archives, you can use the same data source name.
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 25
5 WinCC (TIA Portal)
The "SimulateTag" function is used to assign speed values to the three motors
displayed.
The simulated values are archived in an SQL database. You call the page with
a trend archive via the ">>" button (1).
The speed values archived in the database are read out via the trend archive.
Via the icon (2) you call the system page to terminate the Runtime.
2
Siemens AG 2018 All rights reserved
SQL Datenbankzugriff
Entry ID: 61886098, V2.0, 04/2018 26