Add sample for server reports (#960)

* add sample for server reports

* add license and headers for all samples

* add new icons for sp_whoisactive

* address comments and use sqlops node module
This commit is contained in:
Abbie Petchtes
2018-03-22 21:41:14 -07:00
committed by GitHub
parent 27e9e8ec2b
commit 7099b11651
76 changed files with 9139 additions and 4155 deletions

View File

@@ -0,0 +1,15 @@
declare @condition tinyint;
SET @condition = 24;
with
backupInsight_cte (database_id, last_backup, health_check)
as
(
select d.database_id, max(b.backup_start_date) AS last_backup, case when (datediff( hh , max(b.backup_start_date) , getdate()) < @condition) then 1 else 0 end as health_check
from sys.databases as d left join msdb..backupset as b on d.name = b.database_name
group by d.database_id
)
select
sum(health_check) [Within 24hrs],
sum(case when health_check = 0 AND last_backup IS NOT NULL then 1 else 0 end) [Older than 24hrs],
sum(case when health_check = 0 AND last_backup IS NULL then 1 else 0 end) [No backup found]
from backupInsight_cte