I am using dm_os_performance_counters
to query for Data File(s) Size (KB) and Log File(s) Size (KB) of my databases. Here is a copy of the query I am using:
select object_name, counter_name, instance_name, cntr_value, cntr_type
where (counter_name in ('Log File(s) Size (KB)', 'Data File(s) Size (KB)'))
This works on most of my databases, however at seemingly random times some of these cntr_value results are negative numbers. This happens on multiple servers, so I could not relegate it to a specific server having the an issue, and it happens on different databases at different times. When I look at the database properties through Management Studio the files are listed with the correct sizes, it is just from dm_os_performance_counters
. The only way I have found so far to get the server to update the performance counters is to offline and then online the affected database.
If anyone by chance knows why this would be happening, or a better way to force an update on the performance counters I would be greatly appreciative.
Thanks in advance,