I migrated the following query from mssql v1 sensor to mssql v2.

declare @first BIGINT, @second BIGINT
set @first = (select cntr_value from sys.[dm_os_performance_counters] where object_name='SQLServer:Databases' AND counter_name='Transactions/sec' and instance_name='_Total')
WAITFOR DELAY '00:00:01'
set @second = (select cntr_value from sys.[dm_os_performance_counters] where object_name='SQLServer:Databases' AND counter_name='Transactions/sec' and instance_name='_Total')
SELECT @second - @first AS DIFF;

But as result i get "No valid datatable was returned", even though "SELECT @second - @first AS DIFF;" always returns a dataset.


Article Comments

Could you try to add a ; at the end of each line to see if that works out?


Sep, 2016 - Permalink

I had to remove all the semicolons at the end of the lines. Else PRTG executes each line independet from each other. So i cant use @first and @second. Found the info about that in another topic in here.


Sep, 2016 - Permalink

Alright then - it's always one way or the other, depending on the database system :) Glad you figured it out, sorry for the inconvenience.


Sep, 2016 - Permalink