I am trying to calculate the average time a proc is executed from trace file I have collected, I have not work as a developer so I google it and got these three ways they all gave me the same result but my question what is the outcome is it in Second, Minute .. Thank you for your help declare @T table(StartTime datetime) INSERT INTO @T SELECT [StartTime] FROM table_name ;with C(Sec) AS ( select dateadd(SECOND, avg(datediff(second, dateadd(day, datediff(day, 0, StartTime), 0), StartTime)), 0) from @T ) select convert(char(5), dateadd(minute, case when datepart(second, C.Sec) >= 30 then 1 else 0 end, C.Sec), 108) AS Avg_Value from C SELECT CONVERT(Varchar(50), CAST( AVG( CAST( [StartTime] - CAST([StartTime] AS DATE ) AS DECIMAL( 18, 6 ) ) ) AS DATETIME ),114) From Table_name SELECT DATEADD(SECOND, AVG( DATEDIFF( SECOND, 0, CAST([StartTime] as TIME) ) ), 0) FROM ...Table_name
For quick analysis of trace files I sometimes use ClearTrace [
https://www.scalesql.com/cleartrace/] - it might help you. Otherwise if the trace is purely just for one proc, and you know the start and end time of the trace then you have a total duration. Divide that by the number of executions, and you'll have a rough idea of frequency.