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
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