Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Enterprise
Expertise: Intermediate
Aug 11, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Determining Your Session IDs for SQL Server and Oracle

If you work with SQL Server or Oracle you at some point probably will need to determine your unique connection identifier. For SQL Server, the connection identifier is called a Server Process ID or SPID. It can be obtained from the global @@SPID as:
Once the SPID is determined, it can be used to query various system tables (e.g., sysprocesses, sysobjects, etc.) to obtain process information.

For Oracle, the connection identifier is called a Session ID or SID. To get the Session ID, the V$SESSION view must be queried as:

 SELECT sid from v$session where audsid = userenv('sessionid'); 
When the SID is determined, it can be used to find out session information using other Oracle provided system views such as V$SQL.
Andrew Holliday
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date