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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s