Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns the session ID of the current user process.
Note
This is called the server process ID in earlier versions of SQL Server.
Transact-SQL Syntax Conventions
Syntax
@@SPID
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\jerryduffy dbo
See Also
Reference
Configuration Functions
sp_lock (Transact-SQL)
sp_who