sa_diagnostic_statement table

The sa_diagnostic_statement table is owned by the dbo user, and stores the text of statements. A row in this table represents a SQL statement that was executed by the server. Such statements may have been issued by an external source, such as a client request, or by an internal source such as a procedure, trigger, or user-defined function. Internal statements only appear here once per session.

There are two versions of this table: sa_diagnostic_statement, and sa_tmp_diagnostic_statement.

Columns
Column name Column type Column constraint Table constraints
logging_session_id UNSIGNED INT NOT NULL Primary key.
statement_id UNSIGNED BIGINT NOT NULL Primary key.
database_object UNSIGNED BIGINT
line_number UNSIGNED SMALLINT
signature UNSIGNED INT
statement_text LONG VARCHAR NOT NULL

logging_session_id   The logging session during which the statement was submitted.

statement_id   A unique number assigned to the statement for tracing purposes.

database_object   If the statement came from a procedure, trigger, or function, this is the ID as specified in the ISYSOBJECT system table.

line_number   If the statement formed part of a compound statement, this reflects the ordinal position of the statement within the compound statement.

signature   Used internally to group similar queries.

statement_text   The statement text.