marcingminski / sqlwatch

SQL Server Performance Monitor
https://docs.sqlwatch.io
Other
432 stars 170 forks source link

Duplicates rows in [dbo].[sqlwatch_meta_agent_job] #410

Closed kekcjkee closed 3 years ago

kekcjkee commented 3 years ago

Describe the bug In [dbo].[sqlwatch_meta_agent_job] there is a behavior that creates a lot of duplicate record. This can lead to unexpected results. I want to fix this. image

To Reproduce Steps to reproduce the behavior:

  1. Install SQLWATCH and recreate jobs with same name.

Windows Server (please complete the following information):

SQL Server (please complete the following information):

SQLWATCH version (from DACPAC or from sysinstances)

Additional context My suggestions. I will create a pull request for your evaluation. [dbo].[vw_sqlwatch_report_dim_agent_job] - add predicate WHERE [is_record_deleted] = 0 or [is_record_deleted] is null I explain this so that procedures can only work with an up-to-date list of jobs ([dbo].[usp_sqlwatch_internal_expand_checks], for example).

[dbo].[usp_sqlwatch_internal_add_job] - add to the first merge

when not matched by source then
update set
    [is_record_deleted] = 1