Skip to main content

SQL Server

info

SQL Server ingestion reads source tables through SQL time windows. The most common confusion is the row-version timestamp: it is only a version number, not business time. Pair date columns with offset-aware or no-time-zone placeholders as appropriate. Incorrect types can produce empty windows or shifted times.

Entry point: taosExplorer → Data In → Microsoft SQL Server.

The actual reading host is taosX or the selected taosX-Agent. It needs source-table read permissions and an encrypted connection that meets source policy.

1. Prerequisites​

Ask the DBA for the actual host, port, database, identity, and certificate configuration, and confirm the service supports the required TLS. This example assumes source test table dbo.readings with ts, device, and temperature. Confirm the ts type. SQL Server timestamp is a row-version value, not a business-time column.

PrerequisiteHow to confirm
Network and execution hostCheck the source address and port from the actual taosX or taosX-Agent host. The common port is 1433; use actual configuration for named instances rather than inferring connectivity from the default port.
Identity and objectsThis entry point uses SQL Server username/password authentication. The account must connect to the specified database and read the test tables/views. Windows integrated authentication and Kerberos are not capabilities of this entry point.
TLSThe DBA supplies encryption requirements and a trusted CA. Place material on the actual reading host, not the browser host.
Data and targetProvide a committed bounded window, source time types, target precision, and target write permissions.

An authorized TDengine TSDB administrator prepares the following in taosExplorer's Data Browser or the taos CLI:

CREATE DATABASE mssql_demo PRECISION 'ms';
CREATE STABLE mssql_demo.temperatures (ts TIMESTAMP, temperature DOUBLE)
TAGS (device VARCHAR(32));

2. Minimal Configuration​

  1. Add a Microsoft SQL Server data source, select mssql_demo and the agent to use, and enter connection and authentication details.
  2. Configure encryption and CA according to source requirements, then check connectivity. Trust Certificate changes certificate verification; enabling it is not a general troubleshooting solution.
  3. Select a one-minute window known to contain data and explicitly set start, end, and time zone. For datetime2/datetimeoffset, use ${start}/${end} according to their semantics. For datetime/smalldatetime, use the corresponding no-time-zone placeholders, for example:
SELECT ts, device, temperature FROM dbo.readings
WHERE ts >= ${start_no_tz} AND ts < ${end_no_tz} ORDER BY ts;
  1. Retrieve samples from the server and confirm time and value types. Select target temperatures and child table template t_{device}. Map time, temperature, and device separately, then preview, submit, and start.
View source connection and query configuration locations

The database under Connection Configuration is the source database containing dbo.readings; dbo is an SQL schema. Enter the instance name in the next section's connection options. For named instances, obtain the actual port from the DBA rather than reusing the displayed 1433 hint.

SQL Server source service address, port, and database

Authentication uses an authorized SQL Server username and password, separate from the TDengine target identity. Even if a Windows host is logged in with a domain account, this entry point does not automatically switch to integrated authentication.

SQL Server source username and password

Under SQL Query, enter the subtable query if needed, SQL template, start/end times, interval, and delay in order. Match template placeholders to the source time type. Gray examples are not configured queries. Specify an end time on the first run to avoid unintentionally creating a continuous task.

SQL Server SQL template, time boundaries, and window configuration

2.1 Samples and Mapping​

This example maps ts, device, and temperature. Time must come from a business date column, not timestamp/rowversion. Determine numeric types from source table definitions and recognition results.

For sample retrieval, optional processing, and preview steps, see Relational Database Sample Mapping. Select target temperatures and child table template t_{device}. Map temperature to DOUBLE and device to a tag; the preview should generate t_d001.

According to the v3.4.4.2 release notes, when taosExplorer creates a supertable for a SQL Server synchronization task, it prefills target field types, lengths, and DECIMAL(p,s) precision and scale from query metadata instead of uniformly using VARCHAR(128). Review the prefilled values column by column. For fields with unknown or unbounded lengths, determine the type and capacity manually. After creating the table, compare DESCRIBE output with the source definitions. For older versions, confirm whether the delivered version includes this change.

View recognized columns and preview results

The separate multi-column example below shows recognized columns and target rules on the left. The right side, titled Preview Parsing Results, shows source-column processing results. Use it to check column names, values, and types. It does not prove that target data has been written and does not replace the final child table, time, and tag mapping preview.

SQL Server multi-column recognition, target configuration, and parsing result preview

The test_mssql_001 name and various integer columns in the image are not part of this page's temperature exercise. Verify numeric ranges and nulls using actual source columns, then return to temperatures to complete the target preview, submission, and SQL verification. Do not infer source types from text such as uint in column names; use source definitions and recognition results.

3. Key Differences​

Connection optionMeaning and considerations
Application nameIdentifies connection usage at the source; does not determine target table names.
Instance nameThe SQL Server instance, not the database name. This entry point still requires the actual listener host and port of the instance.
Encryption levelSupports Off, On, NotSupported, and Required. Select explicitly according to source policy. Default NotSupported is not a recommendation for secure deployment.
Trust certificateWhen enabled without a CA, skips normal server-certificate trust checks. Use only under an explicit security plan, not merely to establish connectivity.
CASupplies trusted material for certificate verification. It is not the same as ignoring verification. Verify actual TLS behavior after configuration.
Subtable fields and windowsFollow Common Relational Database Rules, not MongoDB's comma-separated field list. Use time placeholders in pairs.

Entering an instance name does not automatically enable SQL Browser discovery. A Windows reading host also needs the actual instance port. Ask the SQL Server administrator for the instance host, TCP listener port, and database name, then check from the actual reading host. Knowing an instance name or reaching SQL Browser does not prove the connection endpoint is usable.

SQL Server instance, application name, encryption, and certificate settings

The new-task UI initially sets Encryption to Off. Direct connection parameters use a different default when the encryption option is omitted. In the UI, explicitly select the level required by the source. The initial form value is not a universal default across entry points.

${start}/${end} expand to datetime strings with offsets; ${start_no_tz}/${end_no_tz} have no offset, and ${start_date}/${end_date} contain only dates. datetime2 itself does not store a time zone, so confirm the source data's time convention. Its ability to participate in conversion does not make it time-zone-aware. The UI initially sets query interval to 1 day and delay to 0 seconds; explicitly reduce the window for the first test. Initial samples are 5 rows with a 30-second timeout, not validation of a complete window.

Time placeholders use window bounds as wall-clock time in the task time zone. Datetime expands to second precision, with quotes already added by taosX. For the task time zone source, offset validation triggered by offset-aware placeholder pairs, and source-type read rules, see Time and Time Zone. Query Interval only divides windows; see Query Interval and Delay for the delay watermark and approximately once-per-second continuous checks. Incorrect time types or implicit conversion can produce empty windows or shifted times. Successful execution alone does not prove correct results.

warning

For direct configuration types, defaults, and conditions, see SQL Server Read Parameters. encryption is case-sensitive; unknown values fall back to NotSupported rather than consistently reporting errors. trust_cert=true without a CA skips normal server-certificate verification. With a CA, it uses the custom CA path; when the switch is disabled, the specified CA does not take effect. Verify encryption and identity checking separately in production. Accepted spelling or successful connectivity does not remove this requirement.

SQL Server continuous queries use a fixed 10-second minimum window and have no live_sync_min_window query key. Do not copy the same-named MySQL or PostgreSQL parameter. The task time zone does not automatically set the source session time zone. Queries must return a single result set with unique, nonempty aliases for every column. Check result-set count and column names before saving, rather than discovering problems during sampling.

4. Advanced Options and Write Error Policies​

Before submission, expand Advanced Options and record initial read concurrency, batch, and health-monitoring values. Tune one setting at a time against a baseline under the same load. Before handling errors, distinguish source query failures from target write failures. These policies do not fix SQL Server authentication or query errors. Preview time columns, NULLs, and numeric boundaries using actual samples. Do not map timestamp/rowversion as datetime merely because of its name.

For direct DSN defaults, zero values, and scope of read concurrency and output batches, see Advanced Query Source Parameters. This source collects the entire result of one SQL query before splitting output batches. Reducing batch size cannot limit memory for the whole query. If large windows cause sustained memory growth, reduce the query time range first while observing source queries, execution-host memory, and target results.

For querying error archives and backfill boundaries, see Write Errors and Invalid Data.

5. Verification​

Query the actual target child table in taosExplorer's Data Browser or the taos CLI, for example SELECT ts, temperature, device FROM mssql_demo.t_d001 ORDER BY ts LIMIT 20;, and compare it with the same source window. If the source time type has low precision, do not describe precision that never existed as target-side loss.

6. Troubleshooting​

SymptomChecks
Instance cannot be locatedAsk the source administrator for the actual instance TCP port and check from the reading host. An instance name does not replace an endpoint or provide automatic discovery.
TLS failsCheck source protocols, certificate chain, host name, and client configuration. Do not immediately disable verification.
Time condition errors or no dataCheck for misuse of row-version timestamp or a mismatch between placeholders and date column types.

For other task, write, and runtime issues, see Troubleshooting by Symptom.

7. Stop, Resume, and Limitations​

Stop the original task and record windows. After resuming, check unfinished ranges. Tasks do not automatically migrate stored procedures, SQL Server logins, or business indexes, and do not guarantee capture of all historical changes and deletions.