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:
SELECT @@SPID
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.