--- title: "@@SPID (Transact-SQL)" description: "@@SPID (Transact-SQL)" author: MikeRayMSFT ms.author: mikeray ms.reviewer: "" ms.date: "09/18/2017" ms.prod: sql ms.prod_service: "database-engine, sql-database, synapse-analytics, pdw" ms.technology: t-sql ms.topic: reference ms.custom: "" f1_keywords: - "@@SPID" - "@@SPID_TSQL" helpviewer_keywords: - "@@SPID function" - "session_id" - "server process IDs [SQL Server]" - "IDs [SQL Server], user processes" - "SPID" - "session IDs [SQL Server]" - "process ID of current user process" dev_langs: - "TSQL" monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current" --- # @@SPID (Transact-SQL) [!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)] Returns the session ID of the current user process. ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ```syntaxsql @@SPID ``` [!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)] ## 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. ```sql SELECT @@SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` ID Login Name User Name ------ ------------------------------ ------------------------------ 54 SEATTLE\joanna dbo ``` ## Examples: [!INCLUDE[ssSDWfull](../../includes/sssdwfull-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)] This example returns the [!INCLUDE[ssDW](../../includes/ssdw-md.md)] session ID, the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Control node session ID, login name, and user name for the current user process. ```sql SELECT SESSION_ID() AS ID, @@SPID AS 'Control ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'; ``` ## See Also [Configuration Functions](../../t-sql/functions/configuration-functions-transact-sql.md) [sp_lock (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-lock-transact-sql.md) [sp_who](../../relational-databases/system-stored-procedures/sp-who-transact-sql.md)