ODBC Driver for SQL Server

Build 26.0.9770

DateTimeParameterType

Controls whether datetime parameter values are formatted as SQL literals with three or seven fractional-second digits.

Possible Values

DATETIME2, DATETIME

Data Type

string

Default Value

"DATETIME2"

Remarks

When constructing certain SQL statements — such as the lookup queries issued during upsert operations — the driver formats datetime parameter values as SQL literals embedded directly in the SQL text. The format of these inline literals must match the precision of the target SQL Server column type for equality comparisons to succeed.

Set this property to DATETIME when the target column uses the legacy SQL Server datetime type. The datetime type stores values at millisecond precision (three fractional-second digits). Using the default seven-digit format produces literals that do not compare equal to stored datetime values, which can cause the duplicate-key check to fail and result in insertion errors during upsert operations on tables whose primary key includes a datetime column.

The following values are available:

  • DATETIME2: Formats datetime literals with seven fractional-second digits (yyyy-MM-dd HH:mm:ss.fffffff). This is the default and is appropriate when the target column type is datetime2.
  • DATETIME: Formats datetime literals with three fractional-second digits (yyyy-MM-dd HH:mm:ss.fff). Use this setting when the target column type is the legacy SQL Server datetime type.

Copyright (c) 2026 CData Software, Inc. - All rights reserved.
Build 26.0.9770