Sql-server – Getting VLF info with least privileged to run across multiple servers of different version

sql serversql server 2014sql-server-2012sql-server-2017

Per our monitoring scripts i am thinking to add monitor the status of VLF for each database across different SQL servers in our organization:

We have mix of servers from 2012 to 2019: I've found a really good script here https://www.sqlserverscience.com/tools/detect-databases-high-vlf-count/ but there is a problem with which i need some inputs on how to achieve above

The login which executes any scripts across those 100's of SQL server is not a sys-admin. I know there is a way here https://docs.microsoft.com/en-us/sql/relational-databases/tutorial-signing-stored-procedures-with-a-certificate?view=sql-server-ver15 — but this seems tedious as i think it would need a change across the servers where i would like to run the script

Is there a way i can execute the script with non sys admin privilege to get the VLF info from SQL servers 2012+?

Thanks

Best Answer

I don't think you'll find a way prior to 2016.

As of 2016, you can use the DMV sys.dm_db_log_info instead. In fact, your script does just that, checks for the version and uses one or the other command (the other of course being DBCC LOGINFO, which requires sysadmin).

For sys.dm_db_log_info you can just GRANT VIEW SERVER STATE permission.