Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 2 KB

File metadata and controls

55 lines (42 loc) · 2 KB
title SESSION_ID (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 06/10/2016
ms.prod sql-non-specified
ms.reviewer
ms.suite
ms.technology
database-engine
ms.tgt_pltfrm
ms.topic language-reference
dev_langs
TSQL
ms.assetid 2a0d500a-f6c8-490f-9abd-3ae824986404
caps.latest.revision 9
author barbkess
ms.author barbkess
manager jhubbard

SESSION_ID (Transact-SQL)

[!INCLUDEtsql-appliesto-xxxxxx-xxxx-asdw-pdw_md]

Returns the ID of the current [!INCLUDEssSDW] or [!INCLUDEssPDW_md] session.

Topic link icon Transact-SQL Syntax Conventions (Transact-SQL)

Syntax

-- Azure SQL Data Warehouse 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 [!INCLUDEDWsql] commands.

You can query the view sys.dm_pdw_exec_sessions to retrieve the same information as this function.

Examples

The following example returns the current session ID.

SELECT SESSION_ID();  

See Also

DB_NAME (Transact-SQL)
VERSION (SQL Data Warehouse)