How to monitor if table is empty in Azure SQL?

386 Views Asked by At

I have Azure Dashboard visualizing metrics of Azure SQL And Azure Data Factory. I have Azure Alert and LogicApps sending alert.

Now I would like to build monitoring report if table is empty or if there are data duplicates in Azure SQL. What is recommended too making query? What is recommended tool for displaying report for admin users of Azure solution? What is recommended way to send alert?

1

There are 1 best solutions below

4
On

Keep it simple. Create sql job and just apply checks on it.

USE DATABASEname
select coalesce(count(*) ,0) as CHECKVALUE from dbo.table 
IF CHECKVALUE =0

BEGIN

EXEC msdb.dbo.sp_send_dbmail
  @recipients=N'[email protected]',
  @body='tablename is empty......', 
  @subject ='tablename is empty',
  @profile_name ='yourname',
  @query =
    'USE DATABASEname
     (select coalesce(count(*) ,0) as CHECKVALUE from dbo.table )'

END