From 3850cccd4302ca1d787719804dd9bb200868e0c9 Mon Sep 17 00:00:00 2001 From: Konstantin Taranov Date: Fri, 27 Nov 2020 08:43:17 +0300 Subject: [PATCH] Add TrackApiCursor XE and fix SSMS version info --- Extended_Events/TrackApiCursor.sql | 97 ++++++++++++++++++++++++++++++ SSMS/README.md | 6 +- 2 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 Extended_Events/TrackApiCursor.sql diff --git a/Extended_Events/TrackApiCursor.sql b/Extended_Events/TrackApiCursor.sql new file mode 100644 index 00000000..b91beb3f --- /dev/null +++ b/Extended_Events/TrackApiCursor.sql @@ -0,0 +1,97 @@ +/* +https://blog.pythian.com/extended-events-fetching-api-cursors/ +by Shawn Melton January 3, 2017 +*/ + +DROP EVENT SESSION TrackApiCursor ON SERVER; +GO + +CREATE EVENT SESSION TrackApiCursor ON SERVER +ADD EVENT sqlserver.cursor_close( + ACTION( + sqlserver.client_app_name, + sqlserver.database_name, + sqlserver.is_system, + sqlserver.session_id, + sqlserver.sql_text) + WHERE ( + [sqlserver].[is_system]<>(0) + -- AND [sqlserver].[client_app_name]=N'Steely-Eyed-Missle-Man' + ) +), +ADD EVENT sqlserver.cursor_open( + ACTION( + sqlserver.client_app_name, + sqlserver.database_name, + sqlserver.is_system, + sqlserver.query_hash, + sqlserver.session_id, + sqlserver.sql_text) + WHERE ( + [sqlserver].[is_system]<>(0) + -- AND [sqlserver].[client_app_name]=N'Steely-Eyed-Missle-Man' + ) +), +ADD EVENT sqlserver.rpc_completed( + ACTION( + sqlserver.client_app_name, + sqlserver.database_name, + sqlserver.is_system, + sqlserver.query_hash, + sqlserver.session_id, + sqlserver.sql_text) + WHERE ( + [sqlserver].[is_system]<>(0) + -- AND [sqlserver].[client_app_name]=N'Steely-Eyed-Missle-Man' + ) +) +ADD TARGET package0.event_file(SET filename=N'Track_api_cursor.xel') +WITH ( + MAX_DISPATCH_LATENCY=12 SECONDS, + TRACK_CAUSALITY=ON +); +GO + +ALTER EVENT SESSION TrackApiCursor ON SERVER STATE = START; +GO + +/* Read the data */ +IF OBJECT_ID('tempdb..#XEResults') IS NOT NULL + DROP TABLE #XEResults ; +GO +IF OBJECT_ID('tempdb..#XEResultsParsed') IS NOT NULL + DROP TABLE #XEResultsParsed ; +GO + +-- Create results table to load data from XE files +CREATE TABLE #XEResults +( + [RowID] INT IDENTITY + PRIMARY KEY, + [event_data] XML +); + +-- Load the event data from the file target +INSERT INTO #XEResults + ([event_data]) +SELECT CAST([event_data] AS XML) AS event_data +FROM [sys].[fn_xe_file_target_read_file](N'Track_api_cursor*xel',NULL,NULL,NULL) ; + +--SELECT * FROM #XEResults + +-- Query the Event data from the Target. +SELECT [event].[value]('(@name)[1]', 'varchar(50)') AS event_name +-- , DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), CURRENT_TIMESTAMP), [event].[value]('(@timestamp)[1]', 'datetime2')) AS [timestamp] + ,[event].[value]('(action[@name="session_id"]/value)[1]', 'int') AS [session_id] + ,[event].[value]('(action[@name="database_name"]/value)[1]','varchar(128)') AS [database_name] + ,[event].[value]('(action[@name="client_app_name"]/value)[1]','varchar(500)') AS [client_app_name] + ,[event].[value]('(data[@name="object_name"]/value)[1]', 'varchar(50)') AS [object_name] + ,[event].[value]('(action[@name="sql_text"]/value)[1]','varchar(max)') AS [sql_text] + ,[event].[value]('(data[@name="statement"]/value)[1]', 'varchar(1000)') AS [statement] + ,[event].[value]('(action[@name="attach_activity_id_xfer"]/value)[1]', 'varchar(200)') AS [attach_activity_id_xfer] + ,[event].[value]('(action[@name="attach_activity_id"]/value)[1]', 'varchar(200)') AS [attach_activity_id] +FROM #XEResults +CROSS APPLY [event_data].[nodes]('event') AS [q] ([event]) +ORDER BY DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), CURRENT_TIMESTAMP),[event].[value]('(@timestamp)[1]', 'datetime2')) + ,[event].[value]('(action[@name="attach_activity_id"]/value)[1]', 'varchar(200)'); + diff --git a/SSMS/README.md b/SSMS/README.md index 876784cf..5b5f2cad 100644 --- a/SSMS/README.md +++ b/SSMS/README.md @@ -70,10 +70,10 @@ SSMS 18.x is based on the new Visual Studio 2017 Isolated Shell: The new shell u | Version/Download Link | Info | Build | Release Date | Size, Mb | | --------------------------|----------------|---------------|--------------|---------:| -| [18.7.1 GA Release] | **Latest GA** | 15.0.18358.0 | 2020-07-27 | 635 | -| [18.7. GA Release] | | 15.0.18357.0 | 2020-07-20 | 635 | +| [18.7.1 GA Release] | **Latest GA** | 15.0.18358.0 | 2020-10-27 | 635 | +| [18.7. GA Release] | | 15.0.18357.0 | 2020-10-20 | 635 | | [18.6 GA Release] | | 15.0.18338.0 | 2020-07-22 | 534 | -| [18.5.1 GA Release] | | 15.0.18333.0 | 2020-07-09 | 535 | +| [18.5.1 GA Release] | | 15.0.18333.0 | 2020-06-09 | 535 | | [18.5 GA Release] | | 15.0.18183.0 | 2020-04-07 | 535 | | [18.4 GA Release] | | 15.0.18206.0 | 2019-11-04 | 539 | | [18.3.1 GA Release] | | 15.0.18183.0 | 2019-10-02 | 534 |