• atapia_

    Nice piece of code providing the table was blank, but what happens when #New_Table already contains data as per below.

    Insert into #New_Table

    Values (1,'0000000000')

    ,(2, '1111111111')

    ,(3, '1111111111')

    ,(4, '2222222222')

    ,(5, '3333333333')

    ,(6, '2222222222')

    the code provided would insert 3 more rows of 111111111, 2222222222 categories, thus breaking the Max of 3 rows per National_code.

    The reason for this is that you dont take account of existing rows in New_Table which is a possibility according to the original poster.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices