简体   繁体   中英

What is the T-SQL to list all elastic pools in an Azure SQL Server?

I have more than one Azure SQL Server which each may contain at least one SQL Elastic Pool. I am trying to build a SQL script that can execute a CREATE DATABASE statement on any of those servers and select one of the available pools on that server. To that end, I would like to know the T-SQL statement which would list all the available elastic pools on this server. I have found the SQL below which will list all the databases on the server and which pool they are in:

SELECT d.database_id, d.name, elastic_pool_name
FROM sys.databases d
JOIN sys.database_service_objectives dso ON d.database_id = dso.database_id

However, this only returns master on a new server so I can't tell what the pool name(s) are to create a new database in a pool on the server. I also found this REST API endpoint to list all elastic pools on a server , but I need to execute this in SQL and not via HTTP.

You can get the list of elastic pools on the server from sys.elastic_pool_resource_stats

select distinct @@servername as servername, elastic_pool_name from sys.elastic_pool_resource_stats

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM