Windows Azure SQL Database exposes two Dynamic Managed Views called sys.database_usage and sys.bandwidth_usage that show you the activity for your account. These can queried to understand your account usage from a billing perspective.


The prices for SQL Database editions and IO charges may change in the future. Make sure to utilize current costs in the queries provided to make sure your results are accurate.

Database Usage

For example, here is a query that will show your database storage usage in US dollars for the current month on all the databases on your server:

          SUM ( CASE WHEN USAGE.SKU = 'Web'
                   THEN (Quantity * 9.99/31)
                WHEN USAGE.SKU = 'Business'
                   THEN (Quantity * 99.99/31)
                END ) AS CostInDollars
FROM      sys.Database_Usage USAGE
WHERE     datepart(yy, TIME) = datepart(yy, GetUTCDate())
AND       datepart(mm, TIME) = datepart(mm, GetUTCDate())

This query has to be run when you are connected to the master database of your server. The output looks like this:

Storage is not the only cost in using SQL Database, you can also have costs associated with transferring data from the data center in which the SQL Database resides. There is no charge for inbound data tranfers. To calculate the cost of outbound data transfers in US dollars for the current month, execute this Transact-SQL on your master database for the server:

SELECT    USAGE.Time_Period,
          CASE WHEN USAGE.Direction = 'Egress'
              THEN 0.15 * USAGE.BandwidthInKB/(1024*1024)
          END AS CostInDollars
          SELECT    Time_Period,
                    SUM(Quantity) AS BandwidthInKB
          FROM      sys.Bandwidth_Usage
          WHERE     Direction =
                    AND    datepart(yy, TIME) = datepart(yy, GetUTCDate())
                    AND    datepart(mm, TIME) = datepart(mm, GetUTCDate())
                    AND    class = 'External'
          GROUP BY  Time_Period, Direction

The output looks like this:


Do you have a better way to accomplish the same thing in an Azure SQL Database? Post it in the comments below; make sure to test it on an Azure SQL Database first. Do you have questions, concerns, comments? Post them below and we will try to address them.