PDC_REPORT_CreazioneDB/sql/storedTestbes/dbo_SubscribedCustomer_Compare.sql
2025-06-06 19:02:52 +02:00

28 lines
1.4 KiB
Transact-SQL

CREATE procedure [dbo].[SubscribedCustomer_Compare]
AS
BEGIN
SET NOCOUNT ON;
TRUNCATE TABLE [C6StampeCentralizzate].[dbo].[SubscribedCustomer_ComparedResults]
INSERT INTO [C6StampeCentralizzate].[dbo].[SubscribedCustomer_ComparedResults] ([Rete], [FiscalCode], [DateOfMonitoring], [Description])
SELECT hp.[Rete], hp.[FiscalCode], hp.[DateOfMonitoring], 'Cliente mancante in lista Fideuram'
FROM [C6StampeCentralizzate].[dbo].[SubscribedCustomer_HP] hp
LEFT OUTER JOIN [C6StampeCentralizzate].[dbo].[SubscribedCustomer_Bank] bank
ON hp.[Rete] = bank.[Rete] and
hp.[FiscalCode] = bank.[FiscalCode] and
hp.[DateOfMonitoring] = bank.[DateOfMonitoring]
WHERE
bank.[Rete] IS NULL OR
bank.[FiscalCode] IS NULL OR
bank.[DateOfMonitoring] IS NULL
INSERT INTO [C6StampeCentralizzate].[dbo].[SubscribedCustomer_ComparedResults] ([Rete], [FiscalCode], [DateOfMonitoring], [Description])
SELECT bank.[Rete], bank.[FiscalCode], bank.[DateOfMonitoring], 'Cliente mancante in lista HP'
FROM [C6StampeCentralizzate].[dbo].[SubscribedCustomer_Bank] bank
LEFT OUTER JOIN [C6StampeCentralizzate].[dbo].[SubscribedCustomer_HP] hp
ON bank.[Rete] = hp.[Rete] and
bank.[FiscalCode] = hp.[FiscalCode] and
bank.[DateOfMonitoring] = hp.[DateOfMonitoring]
WHERE
hp.[Rete] IS NULL OR
hp.[FiscalCode] IS NULL OR
hp.[DateOfMonitoring] IS NULL
END