-- Run this through each application's *runtime* connection string.
-- Expected: EffectiveTaskHub differs for unrelated Function apps.
SELECT
  USER_NAME() AS EffectiveTaskHub,
  APP_NAME() AS ConnectionApplicationName,
  (SELECT Value FROM dt.GlobalSettings WHERE Name = 'TaskHubMode') AS TaskHubMode;
GO

-- Run as an administrator to see the existing logical runtimes.
SELECT TaskHub, RuntimeStatus, COUNT_BIG(*) AS Instances
FROM dt.Instances
GROUP BY TaskHub, RuntimeStatus
ORDER BY TaskHub, RuntimeStatus;
GO

SELECT TaskHub, COUNT_BIG(*) AS PendingEvents
FROM dt.NewEvents
GROUP BY TaskHub
ORDER BY TaskHub;
GO

SELECT TaskHub, COUNT_BIG(*) AS PendingActivities
FROM dt.NewTasks
GROUP BY TaskHub
ORDER BY TaskHub;
