Explainer
Why an OPC server alone cannot move SQL Server recipes
Short answer
An OPC server only exposes controller variables; it never opens a database connection, reads a recipe row or schedules a transfer. Moving SQL Server recipes into and out of a controller needs an explicit bridge: a database-to-OPC client, a transaction-group module or a small application that reads rows, writes and reads tags both ways, and logs every result.

On this page
An OPC server is a variable gateway, not a database client. It exposes controller tags to any OPC client, and that is the whole of its job: it cannot read a SQL Server table, cannot interpret a recipe row, cannot schedule a download, and keeps no history of its own. The transfer works when you add an explicit bridge between the two: a database-to-OPC client, a transaction-group module, or a small application of your own that reads rows from SQL Server, writes and reads controller tags through the OPC server in both directions, and logs every result. This article names what that bridge must do, walks one recipe download with real numbers, and ends with the decision for each variant of the job.
What an OPC server actually does #
OPC compliance is an interface statement, not a database feature. A data-access server maps controller variables to named, addressable items and serves three operations against them: read the current value, write a value, and subscribe so a client receives changes pushed to it. Item type and access rights travel with each item. Nothing in that model knows what a recipe is: the server never opens a database connection, has no table semantics, holds no scheduler, and a classic data-access server also stores no history — serving current values and storing history are different roles for different software.
That is why "the strategy is OPC compliant, so the transfer should just work" fails as a plan. The compliance claim tells you a client can move individual tag values. It says nothing about reading a row of setpoints from a table and delivering each one to the right tag, in order, with confirmation — that orchestration has to live in software you add.
The four jobs, and which one moves what #
- Editing and scheduling in SQL Server: handled by any language with a database driver — a small C# or VB application with entry forms that write approved recipe rows. This piece never touches OPC.
- Recipe download, database to controller: needs software that reads the row and writes the tags. The OPC server will not initiate anything on its own.
- Recipe upload, controller to database: the same bridge in reverse. The OPC server can serve current values, but it cannot insert a row anywhere.
- History logging: a continuous, buffered job for a dedicated logging client or a historian, not for the recipe path.
Every movement after the first crosses the OPC server, and in each case the moving party is a client on the far side of it. An OPC server sits and answers; it never starts a transfer in either direction.
What the bridge must do #
Whatever form it takes, the software between SQL Server and the controller has six jobs:
- Open and keep a database connection — ODBC or a native client — with its own credentials and error handling.
- Hold the mapping: which column feeds which tag, with what type conversion.
- Decide when to act: a polled request tag, a schedule table, or an operator command.
- Act as the OPC client: resolve item IDs, write each value, read results back.
- Check every result: the write return code, the item quality, and the strategy's own acknowledgement are three different confirmations.
- Log each transfer: a result row with timestamp, recipe identity, and per-item status.
Three implementation routes cover essentially every plant:
- A commercial database-to-OPC client. MatrikonOPC's OPC Client for ODBC is documented to let any ODBC-compliant database exchange process data with an OPC server, driven by standard SQL queries you configure — no code to write.
- A transaction-group module. Ignition's SQL Bridge module is documented as transaction groups that act as a bidirectional data bridge between an OPC server and a SQL database: rows become tag writes, and tag reads come back as rows.
- A custom application. Maximum control over editing, scheduling and revision rules; you also own the recovery logic.
All three run on a machine-level Windows box at the line, not inside the controller and not well placed on the database server; in most plants that box is a fanless industrial mini PC mounted in or near the control cabinet.
A worked recipe download #
The example is a design you define, not a vendor default. The table holds a recipe identity column and twelve setpoint columns; the strategy holds twelve receiving tags plus three handshake tags — a request ID the strategy sets, and a done flag and error code the bridge writes. The bridge polls the request tag at 1 s. A sample of the mapping, with types declared:
| SQL column (example) | SQL type | Controller tag (example) | Tag type |
|---|---|---|---|
| RecipeId | INT | Recipe.RequestId | 32-bit integer |
| TempSet_C | DECIMAL(6,1) | Recipe.TempSet | 32-bit float |
| MixTime_S | INT | Recipe.MixTime | 32-bit integer |
| — result — | — | Recipe.DownloadDone | boolean |
SELECT RecipeId, TempSet_C, MixTime_S
FROM dbo.Recipes
WHERE RecipeId = 4127; -- example row
Timing inputs are example assumptions for a machine-level LAN, not vendor limits: 50 ms per OPC write round-trip, 50 ms per read-back. One download then costs 12 writes × 50 ms = 0.6 s, plus 12 read-backs × 50 ms = 0.6 s, plus two handshake writes ≈ 0.1 s — about 1.3 s in total, and with the 1 s poll the recipe is fully in the controller within roughly 2.3 s of the request. Forty downloads across an 8-hour shift occupy 40 × 1.3 s = 52 s of transfer time, about 0.2% of the shift (52 of 28,800 s): you design against poll load and failure recovery, not bandwidth.
The acceptance sequence is what makes it production-grade; each step is a gate:
- The bridge sees RequestId change.
- It reads the row and converts each column to the mapped tag's type.
- It writes the twelve setpoints and records each write result.
- It reads all twelve back and compares them to the row.
- It writes DownloadDone with the error code: zero on success, the first failing item's index otherwise.
- The strategy validates the received setpoints against its own interlock limits before copying any of them into active use — a bridge moves data and never overrides a safety function.
Step 6 belongs in the strategy, not the bridge: the bridge can confirm the wire carried 180.0, and only the strategy can decide whether 180.0 is a legal value for this machine.
A written value is not a kept value #
A write result of "good" confirms one thing: the server delivered the value to the controller's communications layer. It does not confirm the running strategy accepted it. A strategy that owns the tag can overwrite your value within one scan cycle, leaving the tag showing the strategy's value with a fresh timestamp while your write result still reads success.
Two rules prevent the classic failure in which database and machine recipes overwrite each other repeatedly:
- Give the bridge its own tags. The handshake group belongs to the bridge; the strategy only reads it and copies validated values into the tags it owns. No tag has two writers.
- Treat requested, received and accepted as three states, and record all three in the result row, so a discrepancy tells you whether the write failed on the wire or the strategy refused the value.
The diagnostics follow from that separation. SQL queries succeed while no tags move: the database half works, so test the OPC half on its own. Writes fail: check item access rights and type conversions. Written values snap back: another writer owns that tag, and the ownership rule above fixes it.
Version compatibility decides before the demo does #
Bridges fail in the field less often on logic than on versions. Before selecting either half of the pair, read the vendor's documented support matrix for your exact combination: OPC server build and interface (classic DA or UA), operating system release, SQL Server version, and the installed ODBC driver. Some legacy database-to-controller utilities are documented only against database releases long out of support, with the vendor stating they were never tested against anything current — treat that boundary as an exclusion, not a challenge.
A demo install is an initial compatibility check, nothing more: it proves the installer runs and dependencies resolve on the bench. It does not verify read/write behavior, recovery after a dropped connection, or performance at your rates. The same discipline applies elsewhere in this stack — validating an older client against a newer server is its own exercise, as in validating Historian Client 2017 against a 2023 R2 SP1 server. And before continuous service, confirm the runtime license on the deployed target: what a SCADA runtime license covers beyond running the project is exactly the territory a bench demo never exercises.
Recipe transfer is not history logging #
Recipe transfer is event-driven — a few transactions per shift, each moving a row. Logging is continuous: a single tag at 1 Hz produces 86,400 values over a day, and neither the recipe bridge nor the OPC server buffers that stream by itself. Keep them as separate configurations even when one product can do both, so a download can never collide with a logging write to the same tag.
The logging direction is covered step by step in Logging PLC values from an OPC server into SQL Server, and whether that stream needs a historian at all is decided in Do you need a historian or just an OPC tag server?.
The decision #
- Recipes in SQL Server, changed often, moving both ways: install a documented bidirectional database-to-OPC bridge — a configured ODBC client or a transaction-group module — on a machine-level box, selected against the support matrix for your exact OPC server build, OS release, database version and driver. The bridge's result log is the transfer audit trail.
- Editing, scheduling or revision rules beyond what the bridge configures: write the custom application on the same lines — database driver, mapping, OPC client, handshake, result log — and keep the strategy as the validator of every value it accepts.
- History only, no recipes: skip the bridge and follow the logging path; a bidirectional recipe module idling as a logger is wasted complexity.
- A candidate documented only against obsolete database versions: exclude it, whatever the demo showed.
In every case the division of labor is fixed: SQL Server holds approved recipes, the bridge moves and logs them, the OPC server transports tag values, and the control strategy alone decides what the machine accepts.
Questions asked
Does an OPC UA server change this answer?
No. OPC UA replaces the classic interfaces with a secure, discoverable client-server model, but it is still a variable gateway: clients read and write named nodes. No UA server speaks SQL, so the database side still needs an ODBC or native client inside a bridge. Only the client interface changes; the mapping, trigger, handshake and result log stay exactly as described.
Can the bridge run on the database server itself?
Technically yes, and very small plants do it, but it puts controller traffic, OPC or DCOM chatter and recovery logic on the machine that also serves records to the office network. A separate machine-level box keeps the roles apart: the database server keeps serving data while the bridge box absorbs dropped connections and retries, with its own failure domain on the plant-floor link.
Where should the daily production schedule live?
In the database, as rows with a start time and a recipe identity that the bridge polls, or in the strategy's own clock tasks — never in the OPC server, which has no scheduler. Keep exactly one scheduler. If the bridge triggers downloads from a schedule table while the strategy also fires recipes from its own real-time clock, the two will eventually disagree about which recipe runs.
Can one bridge feed recipes to two controllers?
Yes, because an OPC client can hold connections to several servers at once, and item names are resolved per server. The cost is mapping and bookkeeping: each machine needs its own tag set in the mapping, its own handshake tags and its own result rows, so one failed download cannot be masked by the other machine's success. Verify the bridge product documents multiple server connections before relying on it.
