@@SPID (Transact-SQL)
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
Returns the session ID of the current user process.
Transact-SQL syntax conventions
Syntax
@@SPID
Note
To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions documentation.
Return Types
smallint
Remarks
@@SPID can be used to identify the current user process in the output of sp_who.
Examples
This example returns the session ID, login name, and user name for the current user process.
SELECT @@SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name';
Here is the result set.
ID Login Name User Name
------ ------------------------------ ------------------------------
54 SEATTLE\joanna dbo
Examples: Azure Synapse Analytics and Analytics Platform System (PDW)
This example returns the Azure Synapse Analytics session ID, the SQL Server Control node session ID, login name, and user name for the current user process.
SELECT SESSION_ID() AS ID, @@SPID AS 'Control ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name';
See Also
Повратне информације
https://aka.ms/ContentUserFeedback.
Стиже ускоро: Током 2024. године постепено ћемо укидати проблеме са услугом GitHub као механизам повратних информација за садржај и заменити га новим системом повратних информација. За додатне информације, погледајте:Пошаљите и прегледајте повратне информације за