Skip to content

Instantly share code, notes, and snippets.

@kr153
Created April 18, 2022 12:52
Show Gist options
  • Select an option

  • Save kr153/e92b2d274853cd66d566298d0969cc73 to your computer and use it in GitHub Desktop.

Select an option

Save kr153/e92b2d274853cd66d566298d0969cc73 to your computer and use it in GitHub Desktop.
get the number of batch executions per time period
-- First PASS
DECLARE @First INT
DECLARE @Second INT
SELECT @First = cntr_value
FROM sys.dm_os_performance_counters
WHERE
OBJECT_NAME = 'SQLServer:SQL Statistics' AND -- Change name of your server ' AND -- Change name of your server
counter_name = 'Batch Requests/sec'-- AND
--instance_name = 'XC21801'; -- Change name of your database
-- Following is the delay
WAITFOR DELAY '00:01:00'
-- Second PASS
SELECT @Second = cntr_value
FROM sys.dm_os_performance_counters
WHERE
OBJECT_NAME = 'SQLServer:SQL Statistics' AND -- Change name of your server
counter_name = 'Batch Requests/sec' --AND
--instance_name = 'XC21801'; -- Change name of your database
SELECT (@Second - @First) 'TotalTransactions'
GO
--SQLServer:SQL Statistics
--Batch Requests/sec
--select * from sys.dm_os_performance_counters order by counter_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment