Azure SQL Database Script for Size

Sometimes you may not want to flip over to the Azure portal to grab the database size, such as the used space below.

usedspace.JPG

So here is a handy script to run under the context of the database of interest.


SELECT
       SUM(CAST (FILEPROPERTY (name, 'SpaceUsed') AS BIGINT) * 8192.) / 1024 / 1024 / 1024  as [Database Size In GBs]
FROM sys.database_files
WHERE type_desc = 'ROWS';

 

8.7gb.JPG

 

Advertisements

1 thought on “Azure SQL Database Script for Size

  1. Pingback: Dew Drop – August 13, 2019 (#3009) | Morning Dew

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.