Ajax, thanks for your response. I'll respond to each of your comments.
"in principle looks like a simple query requirement easily done in access" - that's great news for me, I look forward to the solution.
As for hopelessly convoluted, I'm not sure what you mean. I don't even HAVE a method yet, so what's hopelessly convoluted? The requirement is actually really simple - I just can't think of how to accomplish it in set-based processing.
Your code: Looks great, but how are you going to replace "20101215" 1,700 times and get new results? That sounds like the looping I was wanting to avoid.
Your code only works for one date. I need to find that result for all of the distinct values - not just 20101215.
I agree on that method, if only your code recursively put out results for not just 20101215, but the other 1,699 distinct values as well.
As for my comment about SQL server? Well because of the processing power, I actually might just choose a looping-based solution, but 5 million records with some loops is not much for sql server, and the processing time would probably be very acceptable to my client - a few minutes, perhaps. Probably a cursor, something like this (forgive syntax errors, I'm not in front of any IDE and this is air code) -
Code:
declare @c cursor
declare @thedate varchar(8)
set @c = cursor for (select distinct col1 from tbl_staging)
select @c into @thedate
while @fetchstatus=0
begin
--Here is where a query such as you have proposed would go, if not exist, insert record into errors table, or whatever
end
close @c
deallocate @c