Use below queries to get the session details
SELECT S.Session_ID AS [Session ID], S.Status, S.Host_Name AS [Host], C.Client_Net_Address AS [Client Net Address], S.Login_Time AS [Login Time], CASE WHEN S.Login_Name = S.Original_Login_Name THEN S.Login_Name ELSE S.Login_Name + ' (' +S.Original_Login_Name + ')' end AS [Login Name], S.Program_Name AS [Program], ST.Text AS [Query Text],
CASE S.Transaction_Isolation_Level WHEN 0 THEN 'UNSPECIFIED' WHEN 1 THEN 'READUNCOMITTED' WHEN 2 THEN 'READCOMMITTED' WHEN 3 THEN 'REPEATABLE' WHEN 4 THEN 'SERIALIZABLE' WHEN 5 THEN 'SNAPSHOT' ELSE CAST(S.Transaction_Isolation_Level AS VARCHAR(32)) end AS [Transaction Isolation Level],
S.Memory_Usage AS [Memory Usage Pages], S.CPU_Time AS [CPU Time MS], S.Row_count AS [Row Count], S.Last_Request_Start_Time, S.Last_Request_end_Time, S.Prev_Error, C.Net_Transport, C.Protocol_Type, S.Language, S.Date_Format
FROM SYS.DM_Exec_Sessions AS S FULL OUTER JOIN SYS.DM_Exec_Connections C ON C.Session_ID = S.Session_ID CROSS APPLY SYS.DM_Exec_SQL_Text(C.MOST_RECENT_SQL_HANDLE) ST
WHERE S.Session_ID IS NULL OR S.Session_ID > 50
ORDER BY S.Session_ID
SELECT S.Session_ID AS [Session ID], S.Status, S.Host_Name AS [Host], C.Client_Net_Address AS [Client Net Address], S.Login_Time AS [Login Time], CASE WHEN S.Login_Name = S.Original_Login_Name THEN S.Login_Name ELSE S.Login_Name + ' (' +S.Original_Login_Name + ')' end AS [Login Name], S.Program_Name AS [Program], ST.Text AS [Query Text],
CASE S.Transaction_Isolation_Level WHEN 0 THEN 'UNSPECIFIED' WHEN 1 THEN 'READUNCOMITTED' WHEN 2 THEN 'READCOMMITTED' WHEN 3 THEN 'REPEATABLE' WHEN 4 THEN 'SERIALIZABLE' WHEN 5 THEN 'SNAPSHOT' ELSE CAST(S.Transaction_Isolation_Level AS VARCHAR(32)) end AS [Transaction Isolation Level],
S.Memory_Usage AS [Memory Usage Pages], S.CPU_Time AS [CPU Time MS], S.Row_count AS [Row Count], S.Last_Request_Start_Time, S.Last_Request_end_Time, S.Prev_Error, C.Net_Transport, C.Protocol_Type, S.Language, S.Date_Format
FROM SYS.DM_Exec_Sessions AS S FULL OUTER JOIN SYS.DM_Exec_Connections C ON C.Session_ID = S.Session_ID CROSS APPLY SYS.DM_Exec_SQL_Text(C.MOST_RECENT_SQL_HANDLE) ST
WHERE S.Session_ID IS NULL OR S.Session_ID > 50
ORDER BY S.Session_ID
The postings on your site are http://awriter.org/grademiners-com-review// always excellent. Thanks for the great share and keep up this great work! All the best to you.
ReplyDelete