Chapter 16 - ODBC Error Messages

SQLERROR returns SQLSTATE values as defined by the X/Open and SQL Access Group SQL CAE specification (1992). SQLSTATE values are strings that contain five characters. The following table lists SQLSTATE values that a driver can return for SQLError.

The character string value returned for SQLSTATE consists of a two-character class value followed by a three-character subclass value. A class value of 01 indicates a warning and is accompanied by a return code of SQL_SUCCESS_WITH_INFO. Class values other than 01, except for the class IM, indicate an error and are accompanied by a return code of SQL_ERROR. The class IM is specific to warnings and errors that derive from the implementation of ODBC. The subclass value 000 in any class is for implementation defined conditions within the given class. The assignment of class and subclass values is defined by SQL-92.

Note Although successful execution of a function is indicated typically by a return value of SQL_SUCCESS, the SQLSTATE 00000 also indicates success.

SQLSTATE

ODBC API (Driver Manager) error

00000

Success

01000

General warning

01002

Disconnect error

01004

Data truncated

01006

Privilege not revoked

01S00

Invalid connection string attribute

01S01

Error in row

01S02

Option value changed

01S03

No rows updated or deleted

01S04

More than one row updated or deleted

01S05

Cancel treated as FreeStmt/Close

01S06

Attempt to fetch before the result returned the first rowset

07001

Wrong number of parameters

07006

Restricted data type attribute violation

07S01

Invalid use of default paramater

08001

Unable to connect to data source

08002

Connection in use

08003

Connection not open

08004

Data source rejected establishment of connection

08007

Connection failure during transaction

08S01

Communication link failure

21S01

Insert value list does not match column list

21S02

Degree of derived table does not match column list

22001

String data right truncation

22002

Indicator variable required but not supplied

22003

Numeric value out of range

22005

Error in assignment

22008

Datetime field overflow

22012

Division by zero

22026

String data, length mismatch

23000

Integrity constraint violation

24000*

Invalid cursor state

25000

Invalid transaction state

28000

Invalid authorization specification

34000

Invalid cursor name

37000

Syntax error or access violation

3C000

Duplicate cursor name

40001

Serialization failure

42000

Syntax error or access violation

70100

Operation aborted

IM001

Driver does not support this function

IM002

Data source name not found and no default driver specified

IM003

Specified driver could not be loaded

IM004

Driver's SQLAllocEnv failed

IM005

Driver's SQLAllocConnect failed

IM006

Driver's SQLSetConnectOption failed

IM007

No data source or driver specified; dialog prohibited

IM008

Dialog failed

IM009

Unable to load translation DLL

IM010

Data source name too long

IM011

Driver name too long

IM012

DRIVER keyword syntax error

IM013

Trace file error

S0001

Base table or view already exists

S0002

Base table not found

S0011

Index already exists

S0012

Index not found

S0021

Column already exists

S0022

Column not found

S0023

No default for column

S1000

General error

S1001

Memory allocation failure

S1002

Invalid column number

S1003

Program type out of range

S1004

SQL data type out of range

S1008

Operation canceled

S1009

Invalid argument value

S1010

Function sequence error

S1011

Operation invalid at this time

S1012

Invalid transaction operation code specified

S1015

No cursor name available

S1090

Invalid string or buffer length

S1091

Descriptor type out of range

S1092

Option type out of range

S1093

Invalid parameter number

S1094

Invalid scale value

S1095

Function type out of range

S1096

Information type out of range

S1097

Column type out of range

S1098

Scope type out of range

S1099

Nullable type out of range

S1100

Uniqueness option type out of range

S1101

Accuracy option type out of range

S1103

Direction option out of range

S1104

Invalid precision value

S1105

Invalid parameter type

S1106

Fetch type out of range

S1107

Row value out of range

S1108

Concurrency option out of range

S1109

Invalid cursor position

S1110

Invalid driver completion

S1111

Invalid bookmark value

S1C00

Driver not capable

S1DE0

No data at execution values pending

S1T00

Timeout expired

* In SQL Server Enterprise Manager, you may receive the "Invalid cursor state" error message when Microsoft SQL Server runs out of resources while attempting to save selected tables or a database diagram. This error is returned because of insufficient space in your database or transaction log to complete the save process. To correct this problem, check to see if the database or the transaction log is full. If so, increase the size of the database to accommodate the change. Check other system resources or contact your system administrator.

In addition to the standard ODBC error messages located in your ODBC Programmer's Reference documentation, the SQL Server ODBC driver version 3.70 can return error messages for certain SQLSTATE values, as shown in this table.

SQLSTATE

SQL SERVER DRIVER ERROR

Description

01000

%ld rows sent to SQL Server. Total sent: %ld.

A batch size of rows have been sent to SQL Server using the BCP API.

01000

%ld rows successfully bulk-copied to host-file. Total received: %ld.

A batch size of rows have been written to the host file using the BCP API.

01000

Access to database configured in the DSN has been denied. Default used.

Either the database does not exist or the user does not have permission to access the database. The default database configured for the login ID was used.

01000

An error has occurred during an attempt to access the log file, logging disabled.

The log file for driver statistics or long-running queries could not be used. The logging of driver statistics or long-running queries has been disabled.

01000

Connected to backup server.

The SQL Server version 6.5 primary server was not available, so the connection was made to the fallback server.

01000

Language configured in the DSN is not supported. Default used.

Either the language name is invalid or the language is not installed on the server. The default language configured for the login ID was used.

01000

Null bit data forced to zero.

A bit field containing a NULL is being loaded to a server that does not support NULL bit data. The field was set to zero.

01000

Procedure executed with 'EXEC'. No output parameters returned.

The procedure could not be executed as an RPC and output parameters were specified. Because the procedure had to be executed with EXEC, no output parameters will be stored.

01000

SQL Debugging disabled.

SQL Debugging could not be enabled, probably because the SQL Server is not configured for SQL debugging.

01000

The ODBC catalog stored procedures installed on server %s are version %s; version %02d.%02d.%4.4d or later is required to ensure proper operation. Please contact your system administrator.

Install the ODBC catalog stored procedures by executing \Msqql7\Install\Instcat.sql.

01000

Zero length data forced to length 1.

A zero-length binary or character field is being loaded into SQL Server version 6.5 or earlier that does not support zero-length data. The field was forced to a 1 byte blank or binary zero.

01S02

Cursor concurrency changed.

The application requested a concurrency that could not be honored because of the type of request or query. A different concurrency was used instead.

01S02

Cursor type changed.

The application requested a cursor type that could not be honored because of the type of request or query. A different cursor type was used instead.

01S02

Packet size change not honored by server, server size used.

The application requested a nondefault packet size that could not be supported by SQL Server. The server default size was used instead.

01S02

Packet size changed.

The application requested a nondefault packet size that was outside of the limits of allowable size. Either the smallest or largest packet size was used instead, depending if the requested size was too small or too large.

01S02

Login timeout changed.

The application requested a login time-out that was too large. The maximum login time out was used instead.

07006

Conversions not allowed using bcp_moretext.

The application using bcp_moretext must have the same field type as it does the column type.

08004

Server rejected the connection; Access to selected database has been denied.

Either the database does not exist or the user does not have permission to access the database.

08004

Server rejected the connection; Language specified is not supported.

Either the language name is invalid or the language is not installed on SQL Server.

HY024

Database is invalid or cannot be accessed.

Either the database does not exist or the user does not have permission to access the database.

IM006

Packet size change not supported by server, default used.

The application requested a nondefault packet size that SQL Server does not support. The client default size was used.

HY000

All bound columns are read-only.

There must be an updatable column to use SQLSetPos or SQLBulkOperations to change or insert a row.

HY000

An old netlib (%s) has been detected. Please delete it and restart the application.

The netlib that was being loaded was out of date. The driver requires a newer netlib. The problem could be a netlib in the current directory of the application, which is being loaded instead of the one in the system directory, or it could be that the netlib was not installed properly or is corrupted. If the netlib specified in the error text exists elsewhere than in the Windows system directory, delete it. If the netlib exists only in the system directory, install the client utilities on the client and restart the application.

HY000

Attempt to bulk-copy a NULL value into a Server column which does not accept NULL values.

The field contains a NULL value, but the column does not allow NULL values.

HY000

Attempt to bulk-copy an oversized column to the SQL Server.

The length supplied for a column is larger than the column definition in the table.

HY000

Attempt to read unknown version of BCP format file.

The header line in the bcp format file was not version 4.2, 6.0, or 7.0.

HY000

Bad bulk-copy direction. Must be either IN or OUT.

The bcp_init call did not specify a valid direction for the eDirection parameter.

HY000

Bad terminator.

The terminator string supplied in bcp_bind is invalid.

HY000

Bcp host-files must contain at least one column.

No columns were selected to be loaded.

HY000

Cannot generate SSPI context.

The driver could not obtain an SSPI context required for integrated security. The native error will contain the Win32 error code.

HY000

Cannot initialize SSPI package.

The driver could not obtain an SSPI context required for integrated security. The native error will contain the Win32 error code.

HY000

Communication module is not valid. Driver has not been correctly installed.

The network library .dll is corrupted. Install the client utilities on the client and restart the application.

HY000

Connection is busy with results for another hstmt.

The SQL Server ODBC driver allows only one active hstmt. For more information, see "Using Default Result Sets" in Microsoft SQL Server Building Applications.

HY000

Connection is not enabled for BCP.

The application using the BCP API must set the SQLSetConnectAttr or SQL_SS_COPT_BCP attribute before connecting.

HY000

Failure during closing of connection.

The ConnectionClose function in the network library failed. This problem is typically caused by a network or SQL Server problem.

HY000

For BCP, all variable-length data must have either a length-prefix or a terminator specified.

bcp_bind was called with SQL_VARYLEN_DATA, but neither a prefix length nor a terminator was specified.

HY000

Host-file columns may be skipped only when copying into the server.

A bcp out format file specified that a column should be skipped. This is not allowed. Either create a view containing only the desired columns and bcp out from that view, or use the -Q flag to provide a SELECT statement selecting only the desired columns.

HY000

Incorrect host-column number found in BCP format-file.

The format file contains a column number greater than the number of columns in the table.

HY000

I/O error while reading bcp data-file.

N/A

HY000

I/O error while reading BCP format file.

N/A

HY000

I/O error while writing bcp data-file.

N/A

HY000

I/O error while writing bcp error-file.

N/A

HY000

Invalid option.

The eOption parameter to bcp_control was not valid.

HY000

Non-default parameter not allowed after default parameter.

Parameters to a stored procedure cannot have a non-default value after any preceding parameter has been specified with the default value.

HY000

Not enough columns bound.

For a bcp out, not all columns of the table were bound. Either create a view which contains only the desired columns and bcp out from that view or, use the -Q flag to provide a SELECT statement selecting only the desired columns.

HY000

ODBC BCP/Driver version mismatch.

The sqlsrv32.dll and odbcbcp.dll .dlls do not have identical versions. Install the client utilities on the client and restart the application.

HY000

Protocol error in TDS stream.

The TDS stream from the server is invalid. This problem is typically caused by a SQL Server problem. Check the SQL Server error log.

HY000

Table contains less rows than first row count.

A starting row number was supplied, but the table on the server did not contain that number of rows. No rows were copied to the host-file.

HY000

Table contains less rows than last row count.

An ending row number was supplied, but the table on the server did not contain that number of rows.

HY000

Table has no text/image columns.

bcp_moretext was called, but the table does not contain any text or image columns.

HY000

TDS buffer length too large.

The TDS stream from the server is invalid. This problem is typically caused by a SQL Server problem. Check the SQL Server error log.

HY000

Text column data incomplete.

The summation of the lengths supplied by bcp_moretext did not match the length supplied in bcp_bind or bcp_collen.

HY000

The BCP host-file contains less rows than first row count.

A starting row number was supplied, but the host-file did not contain that number of rows. No rows were loaded.

HY000

The row length exceeds SQL Server's maximum allowable size.

The summation of the data lengths for a row is larger than the maximum row size.

HY000

The stored procedure required to complete this operation could not be found on the server (they were supplied with SQL Server). Please contact your system administrator.

Install the ODBC catalog stored procedures by executing \Msqql7\Install\Instcat.sql.

HY000

Unable to load communication module. Driver has not been correctly installed.

The network library .dll specified for the connection does not exist on this client. Install the client utilities on the client and restart the application.

HY000

Unable to open BCP host data-file.

The file name specified in the bcp_init call does not exist or is opened by another application.

HY000

Unable to open BCP error-file.

The error file name specified in the bcp_init call does not exist or is opened by another application.

HY000

Unable to read driver version.

The driver was unable to read the version block in its .DLL. Install the client utilities on the client and restart the application.

HY000

Unexpected EOF encountered in BCP data-file.

During a bcp in operation, end-of-file was detected on the data file while in the middle of processing the last row. This is typically caused by having a different number of columns, types, nullability, or sizes between the original table and the table being loaded.

HY000

Unicode conversion failed.

An error occurred during conversion to or from a Unicode string. The native error will contain the Win32 error code.

HY000

Unicode conversion failed. The code page of the SQL server must be installed on the client system.

The server code page must exist on the client for proper operation. Either clear the Auto Translate check box for the DSN or install the code page of the server on the client. The server code page can be determined by running EXEC sp_server_info 18.

HY000

Unknown token received from SQL Server.

The TDS stream from the server is invalid. This error is typically caused by a problem on the server. Check the SQL Server error log.

HY000

Warning: Partial insert/update. The insert/update of a text or image column(s) did not succeed.

A failure during insertion or update of a text, image, or ntext column occurred. That column will not contain the proper data. Rollback the transaction, if possible.