Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
@@SPID (Transact-SQL)
Collapse the table of content
Expand the table of content

@@SPID (Transact-SQL)

Returns the session ID of the current user process.

ms189535.note(en-US,SQL.90).gifNote:
This is called the server process ID in earlier versions of SQL Server.

Topic link icon Transact-SQL Syntax Conventions


@@SPID

smallint

@@SPID can be used to identify the current user process in the output of sp_who.

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                           

Community Additions

ADD
Show:
© 2015 Microsoft