Store Value in SQL Server Session

Below script will tell you how to store and retrive the data from sql server session. To storing the the value use CONTEXT_INFO.
 like if we want to store the data:
 
DECLARE @IPAddress binary(64)
SET @IPAddress = CONVERT(binary(64), @ClientIPAddress)
SET CONTEXT_INFO @IPAddress

And if we want to get the data from context info :
SELECT context_info  FROM sys.dm_exec_sessions WHERE session_id = @@SPID;
 
Ebook Download
View all
Learn
View all