How to query SLO of "serverless databases" using T-SQL?

Nguyen, Hoa 421 Reputation points
2022-09-19T22:14:50.137+00:00

I have what I perceive as a "database" and can view it in SSMS. I can also see its SLO in SSMS.
It is serverless.

When I query SLO using T-SQL as below
SELECT d.name,
slo.*
FROM sys.databases d
JOIN sys.database_service_objectives slo
ON d.database_id = slo.database_id;

I DO NOT see serverless databases listed in the output grid.

  1. SSMS has my serverless database under the Databases node. But sys.databases does not contain it. I must be querying the wrong table?
  2. What is the T-SQL query to show the SLO of serverless database as displayed in SSMS as seen in snapshot below?

242724-image.png

Thank you very much!

Azure SQL Database
0 comments No comments
{count} vote

Answer accepted by question author
  1. Alberto Morillo 35,401 Reputation points MVP Volunteer Moderator
    2022-09-19T22:50:26.773+00:00

    If you execute the following query:

    SELECT slo_name FROM sys.dm_user_db_resource_governance  
    

    You will get:

    242741-image.png

    On the results, the prefix "SQLDB_GP_S_GEN5" means Azure SQL Database General Purpose (GP) Serverless (S), Gen 5. See other columns of the sys.dm_user_db_resource_governance for more details about the database.

    If I use your query on the context of your serverless database like:

    SELECT  d.name,     
         slo.*      
    FROM sys.databases d     
    JOIN sys.database_service_objectives slo      
    ON d.database_id = slo.database_id;  
    

    You get almost the same:

    242658-image.png

    That "S" on the service objective column "GP_S_Gen5_1" means Serverless.

    Please upgrade the SQL Server Management Studio to the latest version for a better Azure user experience.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Nguyen, Hoa 421 Reputation points
    2022-09-20T14:15:55.207+00:00

    Alberto,
    Thank you very much for the diligent reply. I believe the query. However there is something in my environment or settings that suppress the serverless databases.
    I have 4 databases per SSMS database node:
    243072-image.png

    Yet the t-sql query only shows 1 and suppresses the serverless databases.
    243054-image.png


  2. Nguyen, Hoa 421 Reputation points
    2022-09-20T17:00:52.4+00:00

    Alberto,
    Thank you for your guidance. I see the serverless databases now with the SSMS upgrade.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.