SELECT CAST(event_Data AS xml) AS event_data FROM sys.fn_xe_file_target_read_file('R:\SqlStatements*.xel', NULL, NULL, NULL)
DROP TABLE IF EXISTS #myXeData
SELECT CAST(event_Data AS XML) AS StatementData
INTO #myXeData
FROM sys.fn_xe_file_target_read_file('R:\SqlStatements*.xel', NULL, NULL, NULL)
SELECT * FROM #myXeData
SELECT
StatementData.value('(event/@name)[1]', 'varchar(50)') AS event_name
,StatementData.value('(event/@timestamp)[1]', 'datetime2(0)') AS time_stamp
,StatementData.value('(event/action[@name="database_name"]/value)[1]','nvarchar(128)') AS database_name_
,StatementData.value('(event/data[@name="duration"]/value)[1]','bigint') / 1000 AS duration_ms
,StatementData.value('(event/data[@name="cpu_time"]/value)[1]','bigint') /1000 AS cpu_ms
,StatementData.value('(event/data[@name="physical_reads"]/value)[1]','bigint') AS physical_reads
,StatementData.value('(event/data[@name="logical_reads"]/value)[1]','bigint') AS logical_reads
,StatementData.value('(event/data[@name="row_count"]/value)[1]','bigint') AS row_count
,StatementData.value('(event/data[@name="statement"]/value)[1]','nvarchar(50)') AS statement_
FROM #myXeData AS evts
--ORDER BY time_stamp
ORDER BY duration_ms DESC
https://dba.stackexchange.com/questions/226704/how-to-view-xevent-event-file-data
'SQL SERVER' 카테고리의 다른 글
sql server Lock정보 확인 (0) | 2020.12.09 |
---|---|
패스워드 만료(Expiration) 조회 (0) | 2020.12.08 |
SQL Formatter (0) | 2020.06.05 |
Foreign key로 참조하는 테이블 확인 쿼리 (0) | 2020.03.25 |
sql server 2012 Recommended Trace flag (0) | 2020.02.13 |