In this practice, we will see how to register the Process Values ("PV") in a Database in WinCC Flexible PC Runtime
We have two options:
1.- Configure in History -> Data File.
To use the custom format, it is necessary to create a new user DSN in Administrative Tools -> Data Sources (ODBC) that will reference our Database; I show an example for an Access Database.

2.- As a second alternative, we have the option to create a Script, and as an SQL statement an Insert, to register the values at the time interval we establish, since in our PLC program we can make a Flip/Flop with the time that interests us, and assign the execution of the Script to that variable. It would be equivalent to continuous acquisition mode and file cycle x (Where x equals Time).

Our database is simple, a single table with the following fields:

This Script option can be useful when working with WinCC RT Professional V.11, since when configuring the Historical it does not allow us to select the Database we want; it is a System Database and cannot be easily accessed, other methods must be used, hence the use of the Script.

The equivalent of WinCC Flexible in the new TIA Portal is WinCC RT Advanced, which will have the same appearance as in WinCC Flexible when configuring the historical.
July 2012