Skip to main content

Options

string
required
The hostname or IP address of the MSSQL server.
string
required
The port of the MSSQL server.
string
required
The username for authentication.
string
required
The password for authentication.
string
required
The name of the database.
string
required
The SQL statement to be executed. Values from the arguments are inserted through the placeholders ?1 to ?10. Do not put placeholders in quotes.

Placeholders in the SQL statement

The placeholders ?1 to ?10 refer to the arguments argument1 to argument10. What matters is the number, not the order in which the placeholders appear in the statement. A placeholder may be used more than once. The values are passed to the database as parameters and are treated there as values only, never as part of the statement. This prevents SQL injection and makes manual escaping or quoting unnecessary. This leads to three rules:
  • Placeholders always appear without quotes: WHERE customer = ?1 is correct, WHERE customer = '?1' is not.
  • Placeholders stand for values only. Database, table and column names must be part of the statement itself.
  • Additional characters such as wildcards are appended to the placeholder instead of being written inside it.
A placeholder inside quotes becomes literal text instead of the value that was passed. The two outcomes differ: LIKE '%?1%' searches for the literal text ?1 and returns an empty result without any error, while date >= '?2' causes a conversion error in SQL Server, which the connector reports as a failed query.

Searching with LIKE

The percent signs belong in the statement as separate text and are joined to the placeholder:
WHERE customer LIKE CONCAT('%', ?1, '%') is equivalent. WHERE customer LIKE '%?1%' does not work.

Date and numeric values

Arguments are always passed as text. Use the format yyyy-mm-dd for dates; SQL Server converts it to a date value automatically during comparison:
Query a period with >= for the start and < for the end. Otherwise entries from the last day are missing for columns that include a time. If you want the conversion to be explicit in the statement, use CAST(?2 AS date).

Arguments without a value

Arguments without a value are passed as empty text. In a LIKE search this results in LIKE '%%', which returns all records. For this reason, describe the expected value and format for every argument. argument1 is mandatory: without a value the connector does not run the query.

Arguments

string
required
Value for the first parameter in the SQL statement.
string
Value for the second parameter in the SQL statement.
string
Value for the third parameter in the SQL statement.
string
Value for the fourth parameter in the SQL statement.
string
Value for the fifth parameter in the SQL statement.
string
Value for the sixth parameter in the SQL statement.
string
Value for the seventh parameter in the SQL statement.
string
Value for the eighth parameter in the SQL statement.
string
Value for the ninth parameter in the SQL statement.
string
Value for the tenth parameter in the SQL statement.

Example

The following query finds the contracts of a customer that expire within a given period. The customer name is matched as a partial term, and the period is limited by two date values. Option query:
Description of the arguments:
With the values Muster, 2025-01-01 and 2025-07-01, the database runs the query as if it read kunde LIKE '%Muster%' and laufzeit_ende >= '2025-01-01' AND laufzeit_ende < '2025-07-01'.

Troubleshooting

Check whether the placeholders are enclosed in quotes. '%?1%' is executed as literal text and therefore returns an empty result instead of an error. Use '%' + ?1 + '%' instead.
An argument without a value is passed as empty text. In a LIKE condition this results in '%%', which matches every record. Describe the expected format in the argument, or narrow the query further in the statement.
Pass date values in the format yyyy-mm-dd. For columns that include a time, limit the period with >= and < so that entries from the last day are included.
If the statement cannot be executed, the connector reports it as a failed query and passes on the message from the database; the message is also written to the system log. Such a message does not mean that no matching data exists. Test the statement directly on the database and temporarily replace the placeholders with fixed values there.