Reputation: 1
I'm looking for the equivalent of oracle's
select sys_context ('USERENV', 'SESSIONID') from dual
on MS SQL Server.
I've googled this and found a lot of examples with sys.sysprocesses, sp_who, @@SPID
However @@SSPID seems to have a different meaning than the sessionid in oracle as it appears to be reused over the time. Is there a session identifier on MSSQL server that will not be reused?
Upvotes: 0
Views: 3874
Reputation: 9290
You may try connection_id
from sys.dm_exec_connections
. In this view connection_id
GUID looks like it might do your trick.
select connection_id, * from sys.dm_exec_connections
Upvotes: 1