1. Web edition databases are billed at the 1GB rate for databases below 1GB of total data or at 5GB rate for databases between 1GB and 5GB size.
2. Business edition databases are billed at 10GB increments (10GB, 20, 30, 40 and 50GB).
In a particular day billing is done on the pick DB size. To understand billing better let us take an example, suppose there is Web Edition DB with maximum size 5 GB. On a particular day if database usages are 800MB then you will be charged for 1 GB on that day. If next day DB usage increases to 2 GB then you would be charge for 5 GB. In Business edition charging window is of 10 GB.
SQL Azure introduces two dynamic management views database_usage and bandwidth_usage. These views can be used in TSQL for billing and bandwidth information.
If you want to calculate pricing for any particular type of Database edition probably you would have to do simple mathematical calculations.
Let us say,
R = Monthly Rate of Data base edition. Monthly rate for both web and business edition is different.
D = Number of Day in Month
N = Number of Databases
U = Unit consumption in a given day
Price for Month = (R /D)*U*N
So if
R = 10 $ per month
D = 30 days
N = 1 number of Database
U = 5 unit
Price for Day = (10/30)*1*4 = 1.34 $
TSQL to get current month prices
select sku, sum ( case when sys.database_usage.sku = 'web' then (quantity*10/31) when sys.database_usage.sku = 'business' then (quantity*100/31) end ) as 'cost' from sys.database_usage where datepart(yy,time) = datepart(yy, getutcdate()) and datepart(mm,time) = datepart(mm, getutcdate()) group by sku
In above SQL query
1. 100 $ is monthly charge for business edition and 10 $ is for Web Edition [Assumption]
2. Number of Days is 31
3. Query is running against Master Database.
If you want to list out different units with their edition below query can do the task
Above query will return time, edition and quantity.
select time,sku,quantity from sys.database_usage where datepart(yy,time) = datepart(yy, getutcdate()) and datepart(mm,time) = datepart(mm, getutcdate())
Leave a Reply