Sql-server – Collecting VLF information on all versions of SQL server

performancesql serversql server 2014sql-server-2012

Based on my monitoring collection, i am having an issue while collecting info regarding how many VLF' i have for # of databases in SQL instance.

1st issue – Is there a single script which can be used from 2012 – 2019 SQL versions as standard to get the VLF info across all databases in an instance

2nd issue – how can i get 1st done with least privilege because login we use to collect info is not sysadmin and cant be. So how can i achieve this?

Much appreciated, thanks!

Best Answer

The first problem goes away if you solve the second with a Signed Stored Procedure installed in Master. If there are any version differences required, you can have different versions of the procedure for different SQL Server versions.

Then the script is a just a call to the procedure.

exec sp_GatherVLFStats