Search code examples
sql-serversql-server-2017

Can't get database stats for all databases


I'm running an SQL Server 2017, where I have a monitor user on.

The purpose of the monitor user is to DBCC SQLPERF(LOGSPACE); every once in a while, to monitor how much log space is being used, on all the databases on the server.

I noticed this week, that DBCC SQLPERF(LOGSPACE); suddenly started to only show the database it was currently connected to, and the system databases.

Making the user sysadmin, "fixes" the problem. However I don't consider making a user sysadmin to be a real fix.

The user already has VIEW SERVER STATE permissions, which used to be enough. Which is also listed here: https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-sqlperf-transact-sql?view=sql-server-ver15

A few weeks ago, the Cumulative Update 18 was installed. I don't know if that update introduced the bug.

Does anyone have an idea of how to fix this?


Solution

  • grant connect to any database to the login/monitoruser:

    grant connect any database to monitoruserlogin