Compare Two Tables

  • Jeff Moden (4/7/2009)


    I've not read all the posts on this thread, but why not just use replication for this?

    Hi jeff, this is not about replication.:-D Its about moving data from one table to another. The criteria is move only the records which are not there in the destination table. As part of this this process he want to convert the data type from Int to Varchar. 🙂

    By looking at the replies i think he got the answer 🙂

  • Vijaya Kadiyala (4/8/2009)


    Jeff Moden (4/7/2009)


    I've not read all the posts on this thread, but why not just use replication for this?

    Hi jeff, this is not about replication.:-D Its about moving data from one table to another. The criteria is move only the records which are not there in the destination table. As part of this this process he want to convert the data type from Int to Varchar. 🙂

    By looking at the replies i think he got the answer 🙂

    Indeed, I got the answer I was looking for. My aplogies for brniging up a different subject under the same topic.

  • AFIFM (4/7/2009)


    I have to ask, what are you going to do when you find out that they're equal or not?

    I was trying to find which records in table A that not in table B so I can copy those to table B.

    You can try

    Select ... from a

    except

    select ... from b

    that gives you all rows from table a that are not in table b

  • ulile (4/9/2009)


    AFIFM (4/7/2009)


    Select ... from a

    except

    select ... from b

    that gives you all rows from table a that are not in table b

    From query prespective how is this different than NOT EXISTS clause!!! which is better?

  • The except-clause requires that both parts of the sql-statement have the same structure. The exist-clause needs a subquery to work. Which is faster (or better) I don't no.

  • By looking at the exeuction plan i believe EXISTS is faster...

Viewing 6 posts - 16 through 20 (of 20 total)

You must be logged in to reply to this topic. Login to reply