T-SQL Tutorial T-SQL Advanced Database Management T-SQL References

T-SQL SESSIONPROPERTY() Function



The T-SQL (Transact-SQL) SESSIONPROPERTY() function returns the setting for a specified option of a session.

Syntax

SESSIONPROPERTY(option)

Parameters

option

Required. Specify the current option setting for this session. It can be any of the following values.

OptionDescription
ANSI_NULLSSpecifies whether the ISO behavior of equals (=) and not equal to (<>) against null values is applied.
1 = ON, 0 = OFF
ANSI_PADDINGControls the way the column stores values shorter than the defined size of the column, and the way the column stores values that have trailing blanks in character and binary data.
1 = ON, 0 = OFF
ANSI_WARNINGSSpecifies whether the ISO standard behavior of raising error messages or warnings for certain conditions, including divide-by-zero and arithmetic overflow, is applied.
1 = ON, 0 = OFF
ARITHABORTDetermines whether a query is ended when an overflow or a divide-by-zero error occurs during query execution.
1 = ON, 0 = OFF
CONCAT_NULL_YIELDS_ NULLControls whether concatenation results are treated as null or empty string values.
1 = ON, 0 = OFF
NUMERIC_ROUNDABORTSpecifies whether error messages and warnings are generated when rounding in an expression causes a loss of precision.
1 = ON, 0 = OFF
QUOTED_IDENTIFIERSpecifies whether ISO rules about how to use quotation marks to delimit identifiers and literal strings are to be followed.
1 = ON, 0 = OFF
<Any other string>NULL = Input is not valid.

Return Value

Returns the setting for a specified option of a session.

Example:

The example below shows the usage of SESSIONPROPERTY() function.

SELECT SESSIONPROPERTY('ANSI_NULLS');
Result: 1

SELECT SESSIONPROPERTY('ANSI_PADDING');
Result: 1

SELECT SESSIONPROPERTY('ANSI_WARNINGS');
Result: 1

SELECT SESSIONPROPERTY('ARITHABORT');
Result: 1

SELECT SESSIONPROPERTY('CONCAT_NULL_YIELDS_NULL');
Result: 1

SELECT SESSIONPROPERTY('NUMERIC_ROUNDABORT');
Result: 1

SELECT SESSIONPROPERTY('QUOTED_IDENTIFIER');
Result: 1

❮ T-SQL Functions