P
PatK
I have created the following SQL query to attempt to find the differences
between two identically structured tables. What I do each day is take a
"snapshot" of today's Table. Tomorrow, I will then compare the now
"yesterday" file to today's table.
As a test, I created two identical tables, from real data, and just changed
a couple of the fields. This query is finding those just fine. However, it
is returning MANY other rows. I have come to the determination that that due
to the fact that many of the rows have NULL values in some fields, these is
causing them to be considered unmatched, ie, table1.field1(null) <>
table2.field1(null).
What is the best way to ensure that NULL fields are not kicking out of this
query? Thanks for any pointers!
PatK
SELECT [T003-Snapshot Table].*
FROM [T003-Snapshot Table] LEFT JOIN [Q010-Program-Tracker]
ON [T003-Snapshot Table].[UniqueKey]=[Q010-Program-Tracker].[UniqueKey]
AND [T003-Snapshot Table].[L2]=[Q010-Program-Tracker].[L2]
AND [T003-Snapshot Table].[L3]=[Q010-Program-Tracker].[L3]
AND [T003-Snapshot Table].[L4]=[Q010-Program-Tracker].[L4]
AND [T003-Snapshot
Table].[PortfolioID]=[Q010-Program-Tracker].[PortfolioID]
AND [T003-Snapshot
Table].[Application]=[Q010-Program-Tracker].[Application]
AND [T003-Snapshot Table].[PlanDate]=[Q010-Program-Tracker].[PlanDate]
AND [T003-Snapshot Table].[CompDate]=[Q010-Program-Tracker].[CompDate]
AND [T003-Snapshot Table].[Mandated?]=[Q010-Program-Tracker].[Mandated?]
AND [T003-Snapshot Table].[Completed?]=[Q010-Program-Tracker].[Completed?]
AND [T003-Snapshot
Table].[EligibleCount]=[Q010-Program-Tracker].[EligibleCount]
AND [T003-Snapshot
Table].[ScorecardCount]=[Q010-Program-Tracker].[ScorecardCount]
AND [T003-Snapshot
Table].[CompleteCount]=[Q010-Program-Tracker].[CompleteCount]
WHERE
[Q010-Program-Tracker].[UniqueKey] IS NULL;
between two identically structured tables. What I do each day is take a
"snapshot" of today's Table. Tomorrow, I will then compare the now
"yesterday" file to today's table.
As a test, I created two identical tables, from real data, and just changed
a couple of the fields. This query is finding those just fine. However, it
is returning MANY other rows. I have come to the determination that that due
to the fact that many of the rows have NULL values in some fields, these is
causing them to be considered unmatched, ie, table1.field1(null) <>
table2.field1(null).
What is the best way to ensure that NULL fields are not kicking out of this
query? Thanks for any pointers!
PatK
SELECT [T003-Snapshot Table].*
FROM [T003-Snapshot Table] LEFT JOIN [Q010-Program-Tracker]
ON [T003-Snapshot Table].[UniqueKey]=[Q010-Program-Tracker].[UniqueKey]
AND [T003-Snapshot Table].[L2]=[Q010-Program-Tracker].[L2]
AND [T003-Snapshot Table].[L3]=[Q010-Program-Tracker].[L3]
AND [T003-Snapshot Table].[L4]=[Q010-Program-Tracker].[L4]
AND [T003-Snapshot
Table].[PortfolioID]=[Q010-Program-Tracker].[PortfolioID]
AND [T003-Snapshot
Table].[Application]=[Q010-Program-Tracker].[Application]
AND [T003-Snapshot Table].[PlanDate]=[Q010-Program-Tracker].[PlanDate]
AND [T003-Snapshot Table].[CompDate]=[Q010-Program-Tracker].[CompDate]
AND [T003-Snapshot Table].[Mandated?]=[Q010-Program-Tracker].[Mandated?]
AND [T003-Snapshot Table].[Completed?]=[Q010-Program-Tracker].[Completed?]
AND [T003-Snapshot
Table].[EligibleCount]=[Q010-Program-Tracker].[EligibleCount]
AND [T003-Snapshot
Table].[ScorecardCount]=[Q010-Program-Tracker].[ScorecardCount]
AND [T003-Snapshot
Table].[CompleteCount]=[Q010-Program-Tracker].[CompleteCount]
WHERE
[Q010-Program-Tracker].[UniqueKey] IS NULL;