简体   繁体   English

如何监控 Azure SQL 中的表是否为空?

[英]How to monitor if table is empty in Azure SQL?

I have Azure Dashboard visualizing metrics of Azure SQL And Azure Data Factory.我有 Azure 仪表板可视化 Azure SQL 和 Azure 数据工厂的指标。 I have Azure Alert and LogicApps sending alert.我有 Azure Alert 和 LogicApps 发送警报。

Now I would like to build monitoring report if table is empty or if there are data duplicates in Azure SQL.现在我想在表为空或 Azure SQL 中有数据重复时构建监控报告。 What is recommended too making query?也推荐什么进行查询? What is recommended tool for displaying report for admin users of Azure solution?为 Azure 解决方案的管理员用户显示报告的推荐工具是什么? What is recommended way to send alert?发送警报的推荐方式是什么?

Keep it simple.把事情简单化。 Create sql job and just apply checks on it.创建 sql 作业并对其应用检查。

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

BEGIN

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

END

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM