I ran into some problems trying to use table master.dbo.sysperfinfo to get the batch requests per second, and posted a question on this thread:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=117084The reply from Mladen let me know that there was a known issue with these counters in SQL 2000 that was documented in this Knowledge Base Article:BUG: sysperfinfo counters are not time-adjustedhttp://support.microsoft.com/kb/555064The problem is that all time based counters are aggregated values from the point in time that SQL Server starts.The script below is a workaround that uses two queries with a time delay in between to capture the counter before and after the delay and then calculates the value from the difference divided by the number of seconds.This script is for Batch Requests/sec, but the same idea could be used for any of the time based counters. By adjusting the @seconds parameter in the script, you can adjust the interval over which the value is calculated.-- Find_Batch_Requests_Per_Second.sqldeclare @cntr_value_1 numeric(20,3)declare @cntr_value_2 numeric(20,3)declare @seconds intdeclare @delay_time varchar(12)-- Set interval in seconds to measure the parameterset @seconds = 5-- Set the delay time parameterset @delay_time = right(convert(varchar(30),dateadd(second,@seconds,0),121),12)select @cntr_value_1 = cntr_valuefrom master.dbo.sysperfinfowhere object_name = 'SQLServer:SQL Statistics' AND counter_name = 'Batch Requests/sec'-- Wait for @delay_timewaitfor delay @delay_timeselect @cntr_value_2 = cntr_valuefrom master.dbo.sysperfinfowhere object_name = 'SQLServer:SQL Statistics' AND counter_name = 'Batch Requests/sec'print 'Compute average Batch Requests/sec over time interval of '+ convert(varchar(30),@seconds)+' seconds.'select [Batch Requests/sec] = convert(numeric(20,3),round((@cntr_value_2-@cntr_value_1)/@seconds,3))
Results:Compute average Batch Requests/sec over time interval of 5 seconds.Batch Requests/sec ---------------------- 9.000(1 row(s) affected)
CODO ERGO SUM