SQLSTATE error codes

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 12.2 and above

All error classes returned by Azure Databricks are associated with a 5 character SQLSTATE. A SQLSTATE is a SQL standard encoding for error conditions commonly used by JDBC, ODBC, and other client APIs.

A SQLSTATE consists of two portions: A two character class, and a three character subclass. Each character must be a digit '0' to '9' or 'A' to 'Z'.

While many SQLSTATE values are prescribed by the SQL standard, others are common in the industry, specific to Spark, or Azure Databricks.

Where necessary Spark and Azure Databricks use the 'KD' class and 'K**' subclass ranges for custom SQLSTATEs. The class 'XX' is used for internal errors warranting a bug report.

For an ordered list of error classes see: Error handling in Azure Databricks

Azure Databricks uses the following SQLSTATE classes:

Class 01: warning

SQLSTATE Description and issuing error conditions
01000 warning

Class 02: no data

SQLSTATE Description and issuing error conditions
02000 no data

Class 07: dynamic SQL error

SQLSTATE Description and issuing error conditions
07001 using clause does not match dynamic parameter specifications
07501 The option specified on PREPARE or EXECUTE is not valid.

Class 08: connection exception

SQLSTATE Description and issuing error conditions
08000 connection exception
08001 SQL-client unable to establish SQL-connection
08003 connection does not exist
08004 SQL-server rejected establishment of SQL-connection
08006 connection failure
08KD1 server busy

Class 0A: feature not supported

SQLSTATE Description and issuing error conditions
0A000 feature not supported
0A001 multiple server transactions
0AKD0 Cross catalog or schema operation not supported
0AKD1 Security feature not supported
0AKDC Not supported in Delta
0AKDD Feature requires Delta
0AKDE Feature non enabled for this Delta table
0AKLT Feature not supported for streaming tables
0AKUC Not supported in Unity Catalog
0AKUD Feature requires Unity Catalog
0AXX1 Unexpected column UOID in ingestion gateway
0AXX2 Unexpected table UOID in ingestion gateway

Class 0B: invalid transaction initiation

SQLSTATE Description and issuing error conditions
0B000 invalid transaction initiation

Class 0K: resignal when handler not active

SQLSTATE Description and issuing error conditions
0K000 resignal when handler not active

Class 0N: SQL/XML mapping error

SQLSTATE Description and issuing error conditions
0N000 SQL/XML mapping error

Class 21: cardinality violation

SQLSTATE Description and issuing error conditions
21000 cardinality violation
21506 The same row of a table cannot be the target for more than one of an update, delete or insert operation.
21S01 Insert value list does not match column list
21S02 Degree of derived table does not match column list

Class 22: data exception

SQLSTATE Description and issuing error conditions
22000 data exception
22001 string data, right truncation
22002 null value, no indicator parameter
22003 numeric value out of range
22004 null value not allowed
22005 error in assignment
22006 invalid interval format
22007 invalid datetime format
22008 datetime field overflow
22009 invalid time zone displacement value
2200E null value in array target
2200G most specific type mismatch
2200P interval value out of range
22010 invalid indicator parameter value
22012 division by zero
22015 interval field overflow
22018 invalid character value for cast
2201B invalid regular expression
2201E invalid argument for natural logarithm
22022 indicator overflow
22023 invalid parameter value
22024 unterminated C string
22029 noncharacter in UCS string
22032 invalid JSON text
2203G sql json item cannot be cast to target type
22525 Partitioning key value is not valid.
22531 The argument of a built-in or system provided routine resulted in an error.
22546 The value for a routine argument is not valid.
22K04 Invalid file source connector path.
22KD0 Transient error
22KD1 Invalid URI or PATH
22KD2 Identity claim is unset
22KD3 Cannot evolve source type to target type.
22P02 invalid text representation
22P03 invalid binary representation

Class 23: integrity constraint violation

SQLSTATE Description and issuing error conditions
23001 restrict violation
23502 An insert or update value is null, but the column cannot contain null values.
23505 A violation of the constraint imposed by a unique index or a unique constraint occurred.
23512 The check constraint cannot be added, because the table contains rows that do not satisfy the constraint definition.
23K01 MERGE cardinality violation

Class 24: invalid cursor state

SQLSTATE Description and issuing error conditions
24501 The identified cursor is not open.
24502 The cursor identified in an OPEN statement is already open.

Class 25: invalid transaction state

SQLSTATE Description and issuing error conditions
25000 invalid transaction state
25006 read-only SQL-transaction

Class 28: invalid authorization specification

SQLSTATE Description and issuing error conditions
28000 invalid authorization specification

Class 2B: dependent privilege descriptors still exist

SQLSTATE Description and issuing error conditions
2BP01 dependent objects still exist

Class 2D: invalid transaction termination

SQLSTATE Description and issuing error conditions
2D521 SQL COMMIT or ROLLBACK are invalid in the current operating environment.
2DKD0 Post commit hook failed.

Class 35: invalid condition number

SQLSTATE Description and issuing error conditions
35000 invalid condition number

Class 38: external routine exception

SQLSTATE Description and issuing error conditions
38000 external routine exception

Class 39: external routine invocation exception

SQLSTATE Description and issuing error conditions
39000 external routine invocation exception

Class 3D: invalid catalog name

SQLSTATE Description and issuing error conditions
3D000 invalid catalog name

Class 3F: invalid schema name

SQLSTATE Description and issuing error conditions
3F000 invalid schema name

Class 40: transaction rollback

SQLSTATE Description and issuing error conditions
40000 transaction rollback
40001 serialization failure

Class 42: syntax error or access rule violation

SQLSTATE Description and issuing error conditions
42000 syntax error or access rule violation
42001 Invalid encoder error
42501 The authorization ID does not have the privilege to perform the specified operation on the identified object.
42505 Connection authorization failure occurred.
42517 The specified authorization ID is not allowed to use the trusted context.
42601 A character, token, or clause is invalid or missing.
42602 A character that is invalid in a name has been detected.
42604 An invalid numeric or string constant has been detected.
42605 The number of arguments specified for a scalar function is invalid.
42607 An operand of an aggregate function or CONCAT operator is invalid.
42608 The use of NULL or DEFAULT in VALUES or an assignment statement is invalid.
42611 The column, argument, parameter, or global variable definition is invalid.
42612 The statement string is an SQL statement that is not acceptable in the context in which it is presented.
42613 Clauses are mutually exclusive.
42614 A duplicate keyword or clause is invalid.
42616 Invalid options specified
42617 The statement string is blank or empty.
42621 The check constraint or generated column expression is invalid.
42623 A DEFAULT clause cannot be specified.
42701 The same target is specified more than once for assignment in the same SQL statement.
42702 A column reference is ambiguous, because of duplicate names.
42703 An undefined column or parameter name was detected.
42704 An undefined object or constraint name was detected.
42710 A duplicate object or constraint name was detected.
42711 A duplicate column name was detected in the object definition or ALTER TABLE statement.
42713 A duplicate object was detected in a list or is the same as an existing object.
42723 A routine with the same signature already exists in the schema, module, or compound block where it is defined.
42732 A duplicate schema name in a special register was detected.
42734 A duplicate parameter-name, SQL variable name, label, or condition-name was detected.
4274K Invalid use of a named argument when invoking a routine.
42802 The number of target values is not the same as the number of source values.
42803 A column reference in the SELECT or HAVING clause is invalid, because it is not a grouping column; or a column reference in the GROUP BY clause is invalid.
42804 The result expressions in a CASE expression are not compatible.
42805 An integer in the ORDER BY clause does not identify a column of the result table.
42806 A value cannot be assigned to a variable, because the data types are not compatible.
42807 The data-change statement is not permitted on this object.
42808 A column identified in the INSERT or UPDATE operation is not updatable.
42809 The identified object is not the type of object to which the statement applies.
42815 The data type, length, scale, value, or CCSID is invalid.
42816 A datetime value or duration in an expression is invalid.
42818 The operands of an operator or function are not compatible or comparable.
42821 A data type for an assignment to a column or variable is not compatible with the data type.
42822 An expression in the ORDER BY clause or GROUP BY clause is not valid.
42823 Multiple columns are returned from a subquery that only allows one column.
42825 The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have compatible columns.
42826 The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have the same number of columns.
42830 The foreign key does not conform to the description of the parent key.
42831 Null values are not allowed in a column of a primary key, a column of a unique key, a ROWID column, a row change timestamp column, a row-begin column, a row-end column, or a column of an application period.
42832 The operation is not allowed on system objects.
42836 The specification of a recursive, named derived table is invalid.
42837 The column cannot be altered, because its attributes are not compatible with the current column attributes.
42845 An invalid use of a NOT DETERMINISTIC or EXTERNAL ACTION function was detected.
42846 Cast from source type to target type is not supported.
42852 The privileges specified in GRANT or REVOKE are invalid or inconsistent. (For example, GRANT ALTER on a view.)
42883 No routine was found with a matching signature.
42887 The function or table-reference is not valid in the context where it occurs.
42891 A duplicate constraint already exists.
42893 The object or constraint cannot be dropped, altered, or transferred or authorities cannot be revoked from the object, because other objects are dependent on it.
428B3 An invalid SQLSTATE was specified.
428C4 The number of elements on each side of the predicate operator is not the same.
428EK The schema qualifier is not valid.
428FR A column cannot be altered as specified.
428FT The partitioning clause specified on CREATE or ALTER is not valid.
428GU A table must include at least one column that is not implicitly hidden.
428H2 Data type is not supported in the context where it is being used.
428HD The statement cannot be processed because a column mask cannot be applied or the definition of the mask conflicts with the statement.
42902 The object of the INSERT, UPDATE, or DELETE is also identified (possibly implicitly through a view) in a FROM clause.
42903 Invalid use of an aggregate function or OLAP function.
42908 The statement does not include a required column list.
42939 The name cannot be used, because the specified identifier is reserved for system use.
42996 A specified column may not be used in a partition key.
429BB The data type of a column, parameter, or SQL variable is not supported.
429BQ The specified alter of the data type or attribute is not allowed.
42HA2 Unsupported column type for search index clustering.
42K01 data type not fully specified
42K02 data source not found
42K03 File not found
42K04 Duplicate file
42K05 Name is not valid
42K06 Invalid type for options
42K07 Not a valid schema literal
42K08 Not a constant
42K09 Data type mismatch