在升级到SQL Azure V12之前,我能够通过在master数据库中运行以下查询来获取SQL Azure数据库服务器上所有数据库的服务级别(S1,S2,P1,P2等):
SELECT db.name DatabaseName, ru.sku AS ServiceTier,
slo.name AS ServiceLevel, ru.storage_in_megabytes AS StorageInMB,
ru.[time] ResourceUsageDateTime
FROM sys.databases db
LEFT OUTER JOIN dbo.slo_database_objectives dbslo ON (dbslo.database_id = db.database_id)
LEFT OUTER JOIN dbo.slo_service_objectives slo ON (slo.objective_id = dbslo.configured_objective_id)
LEFT OUTER JOIN sys.resource_usage ru ON (ru.database_name = db.name)
WHERE
ru.[time] = (SELECT MAX([time]) FROM sys.resource_usage);
但是,现在返回错误说: “无效的对象名称'dbo.slo_database_objectives'。”
有没有人知道通过SQL查询执行此操作的另一种方法?
答案 0 :(得分:3)
您可以在数据库上查询:
select DATABASEPROPERTYEX(db_name(),'serviceobjective') serviceobjective,
DATABASEPROPERTYEX(db_name(),'serviceobjectiveid') serviceobjectiveId,
DATABASEPROPERTYEX(db_name(),'edition') edition
答案 1 :(得分:1)
看起来它再次运作:
SELECT
d.name,
slo.*
FROM sys.databases d
JOIN sys.database_service_objectives slo
ON d.database_id = slo.database_id;