--- description: "SESSION_ID (Transact-SQL)" title: "SESSION_ID (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "02/23/2018" ms.prod: sql ms.prod_service: "sql-data-warehouse, pdw" ms.reviewer: "" ms.technology: t-sql ms.topic: reference dev_langs: - "TSQL" author: VanMSFT ms.author: vanto monikerRange: ">= aps-pdw-2016 || = azure-sqldw-latest" --- # SESSION_ID (Transact-SQL) [!INCLUDE[applies-to-version/asa-pdw](../../includes/applies-to-version/asa-pdw.md)] Returns the ID of the current [!INCLUDE[ssSDW](../../includes/sssdw-md.md)] or [!INCLUDE[ssPDW_md](../../includes/sspdw-md.md)] session. ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions (Transact-SQL)](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ```syntaxsql -- Azure Synapse Analytics and Parallel Data Warehouse SESSION_ID ( ) ``` ## Return Value Returns an **nvarchar(32)** value. ## General Remarks The session ID is assigned to each user connection when the connection is made. It persists for the duration of the connection. When the connection ends, the session ID is released. The session ID begins with the alphabetical characters 'SID'. These are case-sensitive and must be capitalized when session ID is used in [!INCLUDE[DWsql](../../includes/dwsql-md.md)] commands. You can query the view [sys.dm_pdw_exec_sessions](../../relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-sessions-transact-sql.md) to retrieve the same information as this function. ## Examples The following example returns the current session ID. ```sql SELECT SESSION_ID(); ``` ## See Also [DB_NAME (Transact-SQL)](../../t-sql/functions/db-name-transact-sql.md) [VERSION (Azure Synapse Analytics)](../../t-sql/functions/version-transact-sql-configuration-functions.md)