Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

@@SPID (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns the session ID of the current user process.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database, Azure SQL Data Warehouse Public Preview.

Topic link icon Transact-SQL Syntax Conventions

@@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\joanna                 dbo                           

Community Additions

ADD
Show:
© 2015 Microsoft