Partager via


2.2.7.10 ERROR

Token Stream Name:

 ERROR

Token Stream Function:

Used to send an error message to the client.

Token Stream Comments:

  • The token value is 0xAA.

Token Stream-Specific Rules:

 TokenType        =   BYTE
 Length           =   USHORT
 Number           =   LONG
 State            =   BYTE
 Class            =   BYTE
 MsgText          =   US_VARCHAR
 ServerName       =   B_VARCHAR
 ProcName         =   B_VARCHAR
 LineNumber       =   USHORT / LONG;  (Changed to LONG in TDS 7.2)

The type of the LineNumber element depends on the version of TDS.

Token Stream Definition:

 ERROR            =   TokenType
                      Length
                      Number
                      State
                      Class
                      MsgText
                      ServerName
                      ProcName
                      LineNumber

Token Stream Parameter Details

 Parameter

 Description

TokenType

ERROR_TOKEN

Length

The total length of the ERROR data stream, in bytes.

Number

The error number.<49>

State

The error state, used as a modifier to the error number.

Class

The class (severity) of the error. A class of less than 10 indicates an informational message.

MsgText

The message text length and message text using US_VARCHAR format.

ServerName

The server name length and server name using B_VARCHAR format.

ProcName

The stored procedure name length and the stored procedure name using B_VARCHAR format.

LineNumber

The line number in the SQL batch or stored procedure that caused the error. Line numbers begin at 1. If the line number is not applicable to the message, the value of LineNumber is 0.

 Class level

 Description

0-9

Informational messages that return status information or report errors that are not severe.<50>

10

Informational messages that return status information or report errors that are not severe.<51>

11-16

Errors that can be corrected by the user.

11

The given object or entity does not exist.

12

A special severity for SQL statements that do not use locking because of special options. In some cases, read operations performed by these SQL statements could result in inconsistent data, because locks are not taken to guarantee consistency.

13

Transaction deadlock errors.

14

Security-related errors, such as permission denied.

15

Syntax errors in the SQL statement.

16

General errors that can be corrected by the user.

17-19

Software errors that cannot be corrected by the user. These errors require system administrator action.

17

The SQL statement caused the database server to run out of resources (such as memory, locks, or disk space for the database) or to exceed some limit set by the system administrator.

18

There is a problem in the Database Engine software, but the SQL statement completes execution, and the connection to the instance of the Database Engine is maintained. System administrator action is required.

19

A non-configurable Database Engine limit has been exceeded and the current SQL batch has been terminated. Error messages with a severity level of 19 or higher stop the execution of the current SQL batch. Severity level 19 errors are rare and can be corrected only by the system administrator. Error messages with a severity level from 19 through 25 are written to the error log.

20-25

System problems have occurred. These are fatal errors, which means the Database Engine task that was executing a SQL batch is no longer running. The task records information about what occurred and then terminates. In most cases, the application connection to the instance of the Database Engine can also terminate. If this happens, depending on the problem, the application might not be able to reconnect.

Error messages in this range can affect all of the processes accessing data in the same database and might indicate that a database or object is damaged. Error messages with a severity level from 19 through 25 are written to the error log.

20

Indicates that a SQL statement has encountered a problem. Because the problem has affected only the current task, it is unlikely that the database itself has been damaged.

21

Indicates that a problem has been encountered that affects all tasks in the current database, but it is unlikely that the database itself has been damaged.

22

Indicates that the table or index specified in the message has been damaged by a software or hardware problem.

Severity level 22 errors occur rarely. If one occurs, run DBCC CHECKDB to determine whether other objects in the database are also damaged. The problem might be in the buffer cache only and not on the disk itself. If so, restarting the instance of the Database Engine corrects the problem. To continue working, reconnect to the instance of the Database Engine; otherwise, use DBCC to repair the problem. In some cases, restoration of the database might be required.

If restarting the instance of the Database Engine does not correct the problem, then the problem is on the disk. Sometimes destroying the object specified in the error message can solve the problem. For example, if the message reports that the instance of the Database Engine has found a row with a length of 0 in a non-clustered index, delete the index and rebuild it.

23

Indicates that the integrity of the entire database is in question because of a hardware or software problem.

Severity level 23 errors occur rarely. If one occurs, run DBCC CHECKDB to determine the extent of the damage. The problem might be in the cache only and not on the disk itself. If so, restarting the instance of the Database Engine corrects the problem. To continue working, reconnect to the instance of the Database Engine; otherwise, use DBCC to repair the problem. In some cases, restoration of the database might be required.

24

Indicates a media failure. The system administrator might have to restore the database or resolve a hardware issue.

If an error is produced within a result set, the ERROR token is sent before the DONE token for the SQL statement, and such DONE token is sent with the error bit set.