Uncategorized

Batch Requests/sec

DECLARE @Batches INT
DECLARE @Delay CHAR(8)
DECLARE @SecToCalc INT

-- set seconds to calculate average
SET @SecToCalc = 5

SET @Delay = '00:00:' + CAST(@SecToCalc AS CHAR(2))

SELECT 
    @Batches = cntr_value 
FROM sys.dm_os_performance_counters
WHERE RTRIM(counter_name) = 'Batch Requests/sec'

WAITFOR DELAY @Delay

SELECT
    ( cntr_value - @Batches ) / CAST(@SecToCalc AS FLOAT) AS 'Batch Requests/sec'
FROM sys.dm_os_performance_counters
WHERE RTRIM(counter_name) = 'Batch Requests/sec'
GO