SET CONTEXT_INFO

Transact-SQL Reference

Transact-SQL Reference

SET CONTEXT_INFO

Associates up to 128 bytes of binary information with the current session or connection.

Syntax

SET CONTEXT_INFO { binary | @binary_var }

Arguments

binary | @binary_var

Specify a binary constant or binary or varbinary variable to associate with the current session or connection.

Remarks

Session context information is stored in the context_info column in the master.dbo.sysprocesses table. This is a varbinary(128) column.

SET CONTEXT_INFO cannot be specified in a user-defined function. You cannot supply a null value to SET CONTEXT_INFO because the sysprocesses table does not allow null values.

SET CONTEXT_INFO does not accept expressions other than constants or variable names. To set the context information to the result of a function call, you must first place the function call result in a binary or varbinary variable.

When you issue SET CONTEXT_INFO in a stored procedure or trigger, unlike in other SET statements, the new value set for the context information persists after the stored procedure or trigger completes.