Medium severitydata integrity
SQL Server Error:
8114
What does this error mean?
SQL Server error 8114 is raised when an implicit or explicit data type conversion fails at runtime — either because the value format is incompatible (e.g. a string '25-04-2026' passed to a DATETIME parameter) or the value falls outside the valid range of the target type (e.g. year 9999 into SMALLDATETIME, which only supports up to 2079). In a data pipeline context this typically surfaces as a failed ADF activity, a dbt model error, or a rejected row in a bulk insert. The error message names the source and target type, but not the offending row — which makes diagnosis slower than it should be.
Common causes
- 1ADF Stored Procedure activity passes a string parameter to a DATETIME or INT column. ADF defaults all parameters to String unless the type is set explicitly in the activity, so the stored procedure receives '2026-04-25T00:00:00' as nvarchar and SQL Server fails the implicit cast.
- 2A source system changes its date format — for example from 'yyyy-MM-dd' to 'dd/MM/yyyy' — without a corresponding change in the pipeline. The downstream CONVERT or implicit cast breaks only on rows with the new format, making this a partial-failure bug that is hard to catch in testing.
- 3A value in the source column is outside the range of the target SQL Server type. SMALLDATETIME accepts dates up to 2079-06-06; TINYINT accepts 0–255; SMALLINT accepts −32768 to 32767. A single out-of-range row in a bulk load will abort the entire batch.
- 4A dbt model casts a column using {{ dbt_utils.safe_cast }} or a raw CAST that encounters NULL-adjacent bad data (e.g. empty string '' cast to INT), raising 8114 instead of a NULL. This happens when the source table has loose typing and the warehouse schema expects strict types.
- 5A MERGE statement or INSERT...SELECT joins two tables where one side stores amounts as NVARCHAR and the other expects DECIMAL. SQL Server attempts implicit conversion row-by-row and fails on the first value that contains a comma, currency symbol, or whitespace.
- 6A Synapse or Azure SQL linked server query pushes a predicate down to a remote SQL Server where column collation or type differs. The remote server raises 8114 on the implicit cast, and the error surfaces in the calling pipeline without a clear pointer to the remote table.
- 7A legacy SSIS package or stored procedure uses SET IMPLICIT_TRANSACTIONS ON with a datatype mismatch in a batch — the transaction rolls back on 8114, and the error appears in ADF logs as a generic activity failure with the original 8114 nested inside.
How to fix it
- 1Step 1 — Identify the exact value that fails. Run TRY_CONVERT against the source column to find all rows that cannot be converted: SELECT id, suspect_col FROM source_table WHERE TRY_CONVERT(datetime, suspect_col) IS NULL AND suspect_col IS NOT NULL; This returns only the offending rows without raising an error.
- 2Step 2 — Check the error message for the type pair. The message reads 'Error converting data type X to Y'. Map X and Y to find the conversion point. If X is nvarchar and Y is datetime, the fix is a format-aware CONVERT: SELECT CONVERT(datetime, '2026-04-25', 120); Style code 120 = ISO yyyy-MM-dd HH:mm:ss. A full list of style codes: https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql
- 3Step 3 — In ADF Stored Procedure activities: open the activity → Parameters tab → change the Type dropdown from String to DateTime (or the matching SQL type). ADF will serialize the value in a SQL Server-compatible format before sending it, bypassing implicit conversion entirely.
- 4Step 4 — In ADF Data Flow or Copy Activity with a Derived Column transformation, add an explicit cast before the sink: toTimestamp(col, 'yyyy-MM-dd HH:mm:ss') for dates, or toInteger(col) for numerics. Place this derived column upstream of any type-sensitive sink mapping.
- 5Step 5 — If the error occurs in a stored procedure called from ADF, add TRY_CONVERT inside the procedure and route bad rows to a quarantine table instead of raising 8114: INSERT INTO bad_rows SELECT * FROM @input WHERE TRY_CONVERT(datetime, date_col) IS NULL; This keeps the pipeline running and gives you an audit trail.
- 6Step 6 — For bulk insert or MERGE failures, add a pre-copy SQL in ADF (Copy Activity → Settings → Pre-copy script) to truncate or stage the data first, then cast explicitly in the INSERT...SELECT that moves data into the final table: INSERT INTO final SELECT CONVERT(decimal(18,2), REPLACE(amount_col, ',', '')) FROM staging;
- 7Step 7 — Prevent recurrence: add a data quality check as an ADF pipeline activity before the load step. Use a Lookup activity with the query from Step 1 and a conditional branch: if row count > 0, fail the pipeline and send an alert rather than letting SQL Server raise 8114 mid-load.
Example log output
ErrorCode=UserErrorExecuteCommandFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error happened when trying to execute the command. Error: Error converting data type nvarchar to datetime.,Source=Microsoft.DataTransfer.ClientLibrary'
SQL Server Error 8114: Error converting data type nvarchar to datetime.
Statement: EXEC dbo.usp_load_sales @load_date = N'25-04-2026', @region = N'NL'Frequently asked questions
Source · learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors