• The numbers need to match within the row and not within the set. I was hoping the identity would help with this but like I said, I'm struggling. For example, I have a lottery ticket with 5 rows. These 5 rows get inserted into LOTTERY_MY_NUM these need to be compared to each row in the LOTTERY_WINNING_NUM table. Each row can have 25 possible combinations. NUM1 on LOTTERY_MY_NUM needs to be checked on NUM1, NUM2, NUM3, NUM4, NUM5. This routine needs to be done for NUM2, NUM3, NUM4, NUM5. Then loop through the 4 remaining rows.

    The reason for the update is, I want to CAST BcolorCode + NUMx. The number is not being replaced, just appending a string to existing value. This is the reason for the datatypes in the NUM fields being varchar and not int.

    When I am sending out the email I will look for that string in the table. This will highlight the matching numbers.

    SET @tableHTML = replace(@tableHTML, '>BcolorCode', ' bgcolor="yellow">')

    Hope this makes sense.