Example SQL Server SQL Handle and SQL Plan

Description:
Example to show the SQL Handle and SQL Plan,
Check the example below:

------------------------------------------------------------------------------------------------------

/*
Get the data for the specific spid, to retrieve the SQL_Handle and Plan_Handle!
*/
SELECT * FROM sys.dm_exec_requests
WHERE session_id = '___'
GO

/*
SQL_HANDLE
*/
SELECT [text] FROM ::fn_get_sql(0x03000800B3DE6E27F2163801319B000001000000)
GO

/*
PLAN_HANDLE Details
*/
SELECT *
FROM sys.dm_exec_plan_attributes(0x060007009543DA324063BE41010000000000000000000000);
GO

/*
PLAN_HANDLE
*/
SELECT query_plan 
FROM sys.dm_exec_text_query_plan (0x060007009543DA324063BE41010000000000000000000000,0,-1);