Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all databases by elastic pool using T-Sql in Azure Sql

There is a need that I need to create a query (T-Sql) where I will list the databases (name) given the elastic pool name. However, I couldn't find a sys.stats*** table or view that will give me this information , the simplest query I want to run is below but it could be any complex query as far as it gives me the list of dbs in an elastic pool

SELECT databaseName from sometable where elasticpoolname ='pool-1'

like image 667
Dan Hunex Avatar asked Sep 21 '26 06:09

Dan Hunex


1 Answers

Answering my own question. I was able to manage list all dbs in a pool thru

SELECT
       @@SERVERNAME as [ServerName],
       dso.elastic_pool_name,
       d.name as DatabaseName,
       dso.edition
FROM
       sys.databases d inner join sys.database_service_objectives dso on d.database_id = dso.database_id
WHERE d.Name <> 'master'
ORDER BY
       d.name, dso.elastic_pool_name
like image 99
Dan Hunex Avatar answered Sep 22 '26 21:09

Dan Hunex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!