Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Find Batch Requests/sec from SYSPERFINFO
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 01/02/2009 :  18:33:29  Show Profile  Reply with Quote
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:

The 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-adjusted

The 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.sql

declare @cntr_value_1 	numeric(20,3)
declare @cntr_value_2 	numeric(20,3)
declare @seconds	int
declare @delay_time	varchar(12)

-- Set interval in seconds to measure the parameter
set @seconds = 5

-- Set the delay time parameter
set @delay_time = right(convert(varchar(30),dateadd(second,@seconds,0),121),12)

	@cntr_value_1 = cntr_value
	object_name	= 'SQLServer:SQL Statistics'	AND
	counter_name 	= 'Batch Requests/sec'

-- Wait for @delay_time
waitfor delay @delay_time

	@cntr_value_2 = cntr_value
	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] =

Compute average Batch Requests/sec over time interval of 5 seconds.
Batch Requests/sec     

(1 row(s) affected)

  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000