Tapahtumat
31. maalisk. klo 23 - 2. huhtik. klo 23
Suurin SQL-, Fabric- ja Power BI -oppimistapahtuma. 31. maaliskuuta – 2. huhtikuuta. Käytä koodia FABINSIDER säästääksesi 400 dollaria.
Rekisteröidy jo tänäänTätä selainta ei enää tueta.
Päivitä Microsoft Edgeen, jotta voit hyödyntää uusimpia ominaisuuksia, suojauspäivityksiä ja teknistä tukea.
Applies to:
SQL Server 2016 (13.x) and later
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
Returns the value of the specified key in the current session context. The value is set by using the sp_set_session_context (Transact-SQL) procedure.
Transact-SQL syntax conventions
SESSION_CONTEXT(N'key')
'key'
The key (type sysname) of the value being retrieved.
sql_variant
The value associated with the specified key in the session context, or NULL if no value has been set for that key.
Any user can read the session context for their session.
SESSION_CONTEXT's MARS behavior is similar to that of CONTEXT_INFO. If a MARS batch sets a key-value pair, the new value will not be returned in other MARS batches on the same connection unless they started after the batch that set the new value completed. If multiple MARS batches are active on a connection, values cannot be set as "read_only." This prevents race conditions and non-determinism about which value "wins."
The following simple example sets the session context value for key user_id
to 4, and then uses the SESSION_CONTEXT function to retrieve the value.
EXEC sp_set_session_context 'user_id', 4;
SELECT SESSION_CONTEXT(N'user_id');
sp_set_session_context (Transact-SQL)
CURRENT_TRANSACTION_ID (Transact-SQL)
Row-Level Security
CONTEXT_INFO (Transact-SQL)
SET CONTEXT_INFO (Transact-SQL)
Tapahtumat
31. maalisk. klo 23 - 2. huhtik. klo 23
Suurin SQL-, Fabric- ja Power BI -oppimistapahtuma. 31. maaliskuuta – 2. huhtikuuta. Käytä koodia FABINSIDER säästääksesi 400 dollaria.
Rekisteröidy jo tänään