Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Home
  • Knowledge base
  • Contact Us
  • Home
  • Connectors
  • Databases
  • MS SQL

Configure the MS SQL Connector

Connect SIA Connect to Microsoft SQL Server, configure queries and stored procedures, write data, and troubleshoot ODBC errors.

Written by Mads Mikkelsen

Updated at September 10th, 2026

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Installation & Technical information
    Introduction SIA Connect Standalone SIA Connect Standalone Plus SIA Connect ANY-Ware Cellular & WiFi connectivity
  • Edge Portal (Next-gen)
    Getting started with the Edge Portal Workspace Configuration Instances Data Interfaces Tools
  • Connectors
    Industrial Connectors Databases Cloud Connectors
  • Scripting & Variables
    Data formatting Advanced Data Processing
  • Developers
    API documentation Shadow API
  • Tutorials & Guides
    InfluxDB AWS IoT Core - Amazon Web Services Microsoft Power BI KaaIoT Siemens S7 AVEVA Insight SIA Connect Demo Rack Grafana Notification & Messaging Azure Cumulocity MQTT MS SQL OPC-UA Server
  • General
  • Configuration in the Edge Portal (legacy)
    Getting started with the UI Connectors Instances Items Mapping Data System Network Tools & Add-ons DigiCert IoT Trust Manager Remote Access & VPN tunneling
+ More

Table of Contents

Before you begin Create an MS SQL instance Create a read item Read data from a stored procedure Write data to MS SQL Understand returned values Verify the configuration Troubleshoot the MS SQL Connector Related articles

Articles in this section:

  • Configure the MS SQL Connector
  • Query examples
  • Setting up the database for external communication

The MS SQL Connector connects SIA Connect to a Microsoft SQL Server database through ODBC. You can use read items to run queries and return database values, and mappings to send complete SQL statements to the database.

This guide explains how to configure an MS SQL instance, create read items, execute stored procedures, write data, interpret returned values, and troubleshoot connection or query errors.

Use a dedicated database account with only the permissions required by the configured queries. The Connector executes the SQL statements it receives and does not automatically parameterize dynamic values.

 

 

Before you begin

Make sure that you have:

  • Installed the MSSQL Connector.
  • The hostname or IP address of the SQL Server.
  • The TCP port used by SQL Server. The default is 1433.
  • The database name.
  • A database username and password.
  • Enabled TCP/IP access and allowed the connection through the relevant firewalls.
  • Granted the database account permission to run the required queries or stored procedures.

For SQL Server-side network preparation, see Setting up the database for external communication.

 

Create an MS SQL instance

  1. In the Edge Portal, go to Instances.
  2. Select Add instance.
  3. Select the MSSQL Connector.
  4. Enter a name for the instance.
  5. Enter the SQL Server hostname or IP address in Address.
  6. Complete the Connector parameters.
  7. Select Create.

The instance attempts to connect when it is enabled and used.

Instance parameters

Parameter Description
Address The hostname or IP address of the SQL Server.
Username The database account used by the Connector.
Password The password for the database account.
Database The database that the Connector opens after signing in.
Connection string Optional additional ODBC connection attributes. Enter each attribute using the format expected by the ODBC driver.
Port The SQL Server TCP port. The default is 1433.

The Connector automatically builds the ODBC connection string from the Address, Port, Username, Password, and Database fields. Values entered in Connection string are appended to it.

 

 

Create a read item

A read item runs the statement in Query default whenever the item is read. The result is stored as the item value.

  1. Open the MS SQL instance.
  2. Open the Items tab.
  3. Select Add item.
  4. Enter a name and UID for the item.
  5. Set the item to allow reading.
  6. Enter a read query in Query default.
  7. Configure the read interval or event-based behavior required by your application.
  8. Select Create.

For example:

SELECT TOP (1) temperature, status
FROM dbo.machine_state
WHERE machine_id = 1
ORDER BY recorded_at DESC

The returned value is a compact JSON array. A result could look like this:

[{"temperature":21.5,"status":"running"}]

Read items are intended for statements that return data. The Connector blocks detected UPDATE, DELETE, INSERT INTO, DROP, and TRUNCATE statements in read queries. This check is not a substitute for database permissions.

 

Avoid unrestricted queries against large tables. Use filters, TOP, and an appropriate ORDER BY clause to limit the returned data.

 

Read data from a stored procedure

A read item can execute a stored procedure that returns a result set. Supported forms include EXEC, EXECUTE, CALL, and the ODBC call escape syntax. A bare procedure name can also be recognized.

For example:

EXEC dbo.GetLatestMachineState @MachineId = 1

The Connector returns the rows from the procedure's result sets in one JSON array. Stored-procedure reads use a five-second query timeout. The ODBC connection used for these reads defaults to TDS version 7.4 and a text size of 16777216 bytes unless those attributes are already present in the connection string.

If a procedure performs setup statements before it runs, leading SET statements can be included before the procedure call.

 

Write data to MS SQL

Each enabled MS SQL instance automatically receives a write-only item named Query write. Its UID ends with _WRITE.

Do not change the UID of the automatically created Query write item.

 

Map a complete SQL statement to the write item. The Connector executes the incoming item value directly as SQL.

For example, the incoming value could be:

INSERT INTO dbo.measurements (source, value)
VALUES ('line_1_temperature', 21.5)

You can also send an UPDATE, DELETE, or stored-procedure statement if the database account is authorized to execute it.

The Connector does not automatically quote, escape, or bind values inside the incoming statement. Validate and escape dynamic content before constructing SQL. Prefer controlled stored procedures or carefully defined mapping templates when values originate outside the database.

 

For additional examples, see Query examples.

 

Understand returned values

Query results are returned as a JSON array. Each database row becomes an object, and each selected column becomes a property.

SQL value Returned JSON value
NULL null
BIT Boolean
Integer types Number when the value is within the JavaScript safe-integer range. Larger BIGINT values are returned as strings.
DECIMAL or NUMERIC Number when it can be represented without significant precision loss. Otherwise, it is returned as a string.
Floating-point types Number when the value is finite.
Binary types Base64-encoded string.
Date, time, and text types String.

JSON stored in a SQL Server text column remains a string inside the returned object. Parse or unwrap it in a mapping if another system requires the nested JSON value.

 

Verify the configuration

  1. Confirm that the instance and the required items are enabled.
  2. Open the instance and check its status and most recent error.
  3. Open a read item and confirm that its value is a JSON array containing the expected columns.
  4. Trigger a test mapping to Query write.
  5. Confirm the inserted or updated value in SQL Server.
  6. Review the item, mapping, and system logs if the expected result is not returned.

 

Troubleshoot the MS SQL Connector

The instance reports Failed to open database or ODBC failed to connect

  • Confirm the Address, Port, Username, Password, and Database values.
  • Confirm that SQL Server is running and listening on the configured TCP port.
  • Check the firewall between SIA Connect and SQL Server.
  • Confirm that SQL Server authentication accepts the configured account.
  • Review any additional ODBC attributes entered in Connection string.

SQL Server reports Login failed for user

Confirm the username and password, the enabled authentication mode, and whether the login is permitted to connect to the server.

SQL Server cannot open the requested database

Confirm the Database value and grant the configured login access to that database.

The connection times out

Check routing, DNS resolution, the TCP port, and firewall rules. The Connector applies a five-second connection and login timeout. Stored-procedure reads also use a five-second query timeout.

The query reports Invalid object name or Invalid column name

Confirm the database, schema, table, view, and column names. Include the schema, such as dbo.machine_state, when needed.

The query reports a syntax error

Run the same statement in a SQL Server query tool using the same database account. Correct SQL Server-specific syntax, quoting, procedure parameters, or missing separators before updating Query default or the mapping.

The query reports a permission error

Grant only the required SELECT, INSERT, UPDATE, DELETE, or EXECUTE permission. Do not grant broader database roles solely to bypass an error.

A read query is blocked

Move modifying statements to a mapping that writes to Query write. Read items reject detected UPDATE, DELETE, INSERT INTO, DROP, and TRUNCATE statements.

The Connector reports Empty query

Confirm that Query default is not empty and that the statement returns a result set. For a stored procedure, confirm that it returns rows rather than only a return code or affected-row count.

A stored procedure fails or returns no data

  • Test the procedure with the same account and parameters in SQL Server.
  • Confirm that the account has EXECUTE permission.
  • Confirm that the procedure returns a tabular result set within five seconds.
  • Use an explicit EXEC statement if a bare procedure name is ambiguous.
  • Check for ODBC query failed, ODBC failed while fetching rows, or ODBC failed while advancing result sets in the item error and logs.

Large numbers or decimals are returned as strings

This protects values from precision loss in JSON. Handle the value as a string, or explicitly convert it in SQL when a numeric JSON value is required and the reduced precision is acceptable.

The connection drops after previously working

Errors such as Communication link failure, Invalid cursor state, Unexpected EOF, Connection reset, or Broken pipe cause the Connector to mark its cached connection for reconnection. Check SQL Server availability and the network path if the error continues.

A write mapping fails

Review the mapping error. It includes the SQL Server error and the query that was executed. Confirm that the incoming value is a complete SQL statement and check for invalid quoting, conversion errors, data-length limits, key conflicts, deadlocks, and insufficient permissions.

 

Related articles

  • Setting up the database for external communication
  • Query examples
  • Install and manage Connectors
  • Create and edit instances
  • Create and edit items
  • Create and edit mappings
  • Troubleshoot Connector, instance, item, and mapping errors
  • Configure and review system logs
ms sql mssql sql server database odbc connector

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Query examples
  • Setting up the database for external communication

0
0
Expand