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!

1 Answer 1


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
  • Thanks, but problem to 1 might not be solved if i am using dmv from this tip mssqltips.com/sqlservertip/5008/… Jun 18, 2020 at 21:39
  • Right. You might have a different procedure for older versions, but the script that calls the proc is the same. Jun 18, 2020 at 21:42
  • thanks but is there a way within same SP i can use that dmv and create a check for version and show results if no match then return cannot be displayed. Just trying to have one common script Jun 18, 2020 at 21:47
  • In one stored procedure you can check SERVERPROPERTY('ProductVersion') and run a different bit of dynamic SQL for each version. Jun 18, 2020 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.