Introduction

If you are the owner of any Azure SQL Database, you must be using the Matrics section of the same in the Azure portal for checking the DTU, CPU, memory percentages continuously. But if you don't have the access to the Azure portal, you might not be able to check this.
Using the below query, you can directly get these numbers from the SQL server itself:
Code
  1. CREATE SCHEMA [SystemMonitor] -- Create if not present
  2. CREATE PROC [SystemMonitor].[GetDBStatus]
  3. @interval INT
  4. AS
  5. BEGIN
  6. DECLARE @edition varchar(50),
  7. @serviceObjective varchar(50)
  8. SELECT
  9. @edition = slo.edition,
  10. @serviceObjective =slo.service_objective
  11. FROM sys.databases d
  12. JOIN sys.database_service_objectives slo
  13. ON d.database_id = slo.database_id
  14. SELECT
  15. AVG(avg_cpu_percent) AS 'AverageCPUPercent',
  16. MAX(avg_cpu_percent) AS 'MaximumCPUPercent',
  17. AVG(avg_data_io_percent) AS 'AverageDataIOPercent',
  18. MAX(avg_data_io_percent) AS 'MaximumDataIOPercent',
  19. AVG(avg_memory_usage_percent) AS 'AverageMemoryPercent',
  20. MAX(avg_memory_usage_percent) AS 'MaximumMemoryPercent',
  21. MAX(end_time) AS 'StartDatetime',
  22. MIN(end_time) AS 'EndDatetime',
  23. @edition AS 'Edition',
  24. @serviceObjective 'ServiceObjective'
  25. FROM sys.dm_db_resource_stats
  26. WHERE end_time < GETDATE()
  27. AND end_time >= DATEADD(minute, (-1 * @interval), getdate()) -- Set the interval as per your requirement to check
  28. END
Result
Get CPU, DataIO And Memory Usages In Azure SQL Through Query
Now if you want to change the pricing tier from the SQL server portal, check the below link.
Change The Azure SQL Pricing Tier Using SQL Query
Enjoy!