In SQL Server, you can use the SESSION_CONTEXT()
function to read the value of a specified key in the current session context.
The key (key/value pair) needs to be set first. This can be done with the sp_set_session_context
stored procedure.
Once a key/value pair has been set for the session, you can use SESSION_CONTEXT()
to return that key’s value.