-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdataprocessed.sql
31 lines (31 loc) · 976 Bytes
/
dataprocessed.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;WITH DataUsage
AS
(
SELECT [type] AS DataUsageWindow,
data_processed_mb AS DataProcessedMB,
CAST(data_processed_mb AS DECIMAL(10,3)) / 1000 AS DataProcessedGB,
(CAST(data_processed_mb AS DECIMAL(10,3)) / 1000) / 1000 AS DataProcessedTB
FROM sys.dm_external_data_processed
),
DataLimit
AS
(
SELECT [name] AS DataLimitWindow,
CASE
WHEN [name] LIKE '%daily%' THEN 'daily'
WHEN [name] LIKE '%weekly%' THEN 'weekly'
WHEN [name] LIKE '%monthly%' THEN 'monthly'
END AS DataUsageWindow,
value AS TBValue,
CAST(value_in_use AS INT) AS TBValueInUse
FROM sys.configurations
WHERE [name] LIKE 'Data processed %'
)
SELECT DL.DataUsageWindow,
DL.TBValueInUse,
DU.DataProcessedMB,
DU.DataProcessedGB,
DU.DataProcessedTB,
(100 / DL.TBValueInUse) * DU.DataProcessedTB AS PercentTBUsed
FROM DataLimit DL
INNER JOIN DataUsage DU ON DL.DataUsageWindow = DU.DataUsageWindow