Last active
January 6, 2017 12:41
-
-
Save bartread/c2129001a7dc9d7c90320e8a0b9e41e6 to your computer and use it in GitHub Desktop.
SQL Server Profiler trace - events by type per second
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT [TimeSlice] = | |
RIGHT(N'0' + CAST(DATEPART(hh, StartTime) AS NVARCHAR(2)), 2) | |
+ N':' | |
+ RIGHT(N'0' + CAST(DATEPART(n, StartTime) AS NVARCHAR(2)), 2) | |
+ N':' | |
+ RIGHT(N'0' + CAST(DATEPART(ss, StartTime) AS NVARCHAR(2)), 2) | |
, te.name AS [EventType] | |
, [EventCount] = COUNT(te.name) | |
, [ReadCount] = SUM(Reads) | |
FROM [YOUR_TRACE_TABLE_SCHEMA].[YOUR_TRACE_TABLE_NAME] AS d | |
INNER JOIN sys.trace_events AS te | |
ON te.trace_event_id = d.EventClass | |
GROUP BY RIGHT(N'0' + CAST(DATEPART(hh, StartTime) AS NVARCHAR(2)), 2) | |
+ N':' | |
+ RIGHT(N'0' + CAST(DATEPART(n, StartTime) AS NVARCHAR(2)), 2) | |
+ N':' | |
+ RIGHT(N'0' + CAST(DATEPART(ss, StartTime) AS NVARCHAR(2)), 2) | |
, te.name | |
ORDER BY [TimeSlice] ASC, te.name ASC; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment