What is the best way to see if a value exists in one table but not in another in sql server. Here is my problem: I want to make sure that all finishers that are in my local db (as designated by their bib number) are also in the results online. Here is something that works, but is very cumbersome. Looking to clean this up. (Notice that one connection is designated by conn and the other by srvr_conn)
Thanks in advance!
i = 0
ReDim LocalBibs(0)
sql = "SELECT Bib FROM IndRslts WHERE RaceSrvrID = " & lRaceID & " AND Place > 0 AND FnlScnds > 0 ORDER BY Bib"
Set rs = conn.Execute(sql)
Do While Not rs.EOF
LocalBibs(i) = rs(0).Value
i = i + 1
ReDim Preserve LocalBibs(i)
rs.MoveNext
Loop
Set rs = Nothing
For i = 0 To UBound(LocalBibs) - 1
sql = "SELECT Bib FROM IndRslts WHERE RaceSrvrID = " & lRaceID & " AND Place = 0 AND FnlScnds = 0 AND Bib = " & LocalBibs(i)
Set rs = srvr_conn.Execute(sql)
If Not rs.EOF And Not rs.BOF Then
lstMissingBibs.AddItem rs(0).Value
End If
Set rs = Nothing
Next i
Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.