2 tables, compare data help??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    2 tables, compare data help??

    by m.r.davies
    I have 2 tables on seperate Db's (and servers)
    I want to use a datareader on the first table to pick the booking ref, and then use that booking ref to query the 2nd DB
    when i have the correct row in the 2nd DB I want to compare each field in the 2 tables to see if they match

    Every time i try and think how i end up with a while loop for the reader on table1 and a while loop for the reader on table 2

    any ideas how i'm going to do this?
    Cheers
  • Hermit Dave

    #2
    Re: 2 tables, compare data help??

    i assum that both the tables on db1 and db 2 have a common id.
    say you want to get booking info from table 1 and then compare it to the
    booking ref in table 2 in db2.
    use a stored proc and get the record info. Not a big fan of datareader as
    its not disconnected... rather prefer
    output parameters if my stored proc returns only one row or a dataset if my
    proc returned more than one records..
    disconnect the dataset or read the output params into a custom bookingInfo
    object

    next fire up another query which will take the booking id (from dataset or
    custom object you populated from output parameter) and return any
    corresponding data from table2 in db2
    if you expect more than one value again.. use a dataset or if only one then
    user output parameters of stored procs

    now you have two objects or two datasets and you just need to iterate them
    both to compare corresponding column values

    Hope this helps,

    --

    Regards,

    HD
    "Mark" <anonymous@disc ussions.microso ft.com> wrote in message
    news:D13A2590-B9D8-4BC3-8234-896443BAAD72@mi crosoft.com...[color=blue]
    > by m.r.davies
    > I have 2 tables on seperate Db's (and servers)
    > I want to use a datareader on the first table to pick the booking ref, and[/color]
    then use that booking ref to query the 2nd DB[color=blue]
    > when i have the correct row in the 2nd DB I want to compare each field in[/color]
    the 2 tables to see if they match[color=blue]
    >
    > Every time i try and think how i end up with a while loop for the reader[/color]
    on table1 and a while loop for the reader on table 2[color=blue]
    >
    > any ideas how i'm going to do this?
    > Cheers[/color]


    Comment

    Working...