Bath Insertion With Comparison.

  • Hi

     

    Tbl1

    ColA Varchar

    ColB Varchar

    ColC Varchar (empty/ have to insert values)

     

    Tbl2

    ColA Varchar

    ColB Varchar

    ColC Varchar

     

    I wish to have a function or procedure which compare all values of Tbl1 with Tbl2 and enter the corresponding value in Tbl1.ColC from Tbl2.ColC. (ColA*ColB is unique in Tbl1 & Tbl2. Tables don’t have any key relation)

     

    Example 

    inset Tbl2.ColC into Tbl1.ColC

    where Tbl1.ColA = Tbl2.ColA

    and Tbl1.ColB = Tble2.ColB

     

    Please advise how to do it for all rows together.

     

    Thanks

    Jawad

  • UPDATE A SET ColC=B.ColC

    FROM Tbl1 A INNER JOIN Tbl B

    ON A.ColA=B.ColA AND A.ColB=B.ColB

Viewing 2 posts - 1 through 1 (of 1 total)

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