What can I do wtih a binary data type in SQL Server to make my life easier?
I recently found out about this nifty feature
DECLARE @p0 varbinary(128)
SET @p0 = --?
SET CONTEXT_INFO @p0
How can I in a reasonable efficient manner store data that makes some sense in this binary slot? Oh, and then access that data in some reasonable way?
SELECT ? = context_info
FROM sys.dm_exec_sessions
WHERE session_id = @@SPID
Update: as pointed out by gbn
SELECT ? = CONTEXT_INFO()
A more useful approach would be to rely on CONTEXT_INFO() to return a Row ID of some context table. Say:
SELECT *
FROM ContextTable
WHERE RowID = CONTEXT_INFO()
That would allow me to query context information.