If you work with SQL Server or Oracle you at some point probably will need todetermine your unique connection identifier. For SQL Server, the connectionidentifier is called a Server Process ID or SPID. It can be obtained from theglobal @@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 getthe 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 sessioninformation using other Oracle provided system views such as V$SQL.