troubleshooting Question

Finding SQL Server Discrepancues

Avatar of Bob Schneider
Bob SchneiderFlag for United States of America asked on
SQLMicrosoft SQL ServerVisual Basic Classic
4 Comments1 Solution29 ViewsLast Modified:

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

Open in new window

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 4 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

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 >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 4 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004