Description: This proc can be ran to display what tables are not loading. It can be used as part of troubleshooting.
Necessary Modification: There are some tables you do not want to monitor for various reasons. To remove these tables from the results set, get their table ID from vol.Tables and insert them into the UnwantedTables temporary table.
--Manually get rid of unwanted tables.INSERT INTO #UnWantedTables(TableID)SELECT131
USE [ODS]GODROPPROCEDUREIFEXISTS [dbo].[usp_DisplayTablesNotLoading]GOSETANSI_NULLSONGOSETQUOTED_IDENTIFIERONGOCREATEPROCEDURE [dbo].[usp_DisplayTablesNotLoading] ASBEGINCREATETABLE #UnWantedTables(TableID BIGINT)CREATECLUSTEREDINDEX CIDX_UNWANTEDTABLES_TABLEID ON #UnWantedTables(TableID)DECLARE @MostRecentDate DATETIMESELECT @MostRecentDate =MAX(DateOfCurrentObservation) FROM [vol].[LoadObservations]INSERT INTO #UnWantedTables(TableID)--Get rid of tables with no recordsSELECT t.TableIDFROM [vol].[Tables] tJOIN [vol].[LoadObservations] loON t.TableID = lo.TableIDGROUP BY t.TableIDHAVINGAVG(CAST(lo.[RowCount] ASBIGINT)) =0UNION--Get rid of tables with no load varianceSELECT t.TableIDFROM [vol].[Tables] tJOIN [vol].[LoadObservations] loON t.TableID = lo.TableIDGROUP BY t.TableIDHAVINGAVG(lo.CurrentThreeSDLevel) =0--Manually get rid of unwanted tables.--INSERT INTO #UnWantedTables(TableID)--SELECT 131SELECT TableID, [TableName]FROM [vol].[Tables]WHERE TableID IN (SELECT t.TableIDFROM [vol].[Tables] tJOIN [vol].[LoadObservations] loON t.TableID = lo.TableIDWHERE t.TableID NOTIN (SELECT TableID FROM #UnWantedTables)AND lo.DateOfCurrentObservation BETWEENDATEADD(DD,-3,CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMPGROUP BY t.TableIDHAVINGAVG(CAST(lo.ChangeFromLastObservation ASFLOAT)) =0)DROPTABLE #UnWantedTablesENDGO