Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which privileges does a user need to query used size in SQL Azure database?

I'm trying to query the consumed size of a SQL Azure database using code from this answer:

SELECT SUM(reserved_page_count)*8.0/1024 FROM sys.dm_db_partition_stats;

That query runs just fine under the database admin, but not under another user - I get

The user does not have permission to perform this action.

and when I try to GRANT SELECT permission I get this error message:

Permissions on server scoped catalog views or system stored procedures or extended stored procedures can be granted only when the current database is master.

If I log to master and try to GRANT there I get this message:

Permissions for system stored procedures, server scoped catalog views, and extended stored procedures cannot be changed in this version of SQL Server.

So it looks like users other than database admin can't get the used space.

How do I query the used space in the SQL Azure database under a user other than database admin?

like image 736
sharptooth Avatar asked Oct 18 '25 14:10

sharptooth


1 Answers

I seem to recall that we had to grant the login "VIEW DATABASE STATE" and "VIEW DEFINITION" in order to run that query.

like image 90
dunnry Avatar answered Oct 20 '25 03:10

dunnry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!