Thank for the reply Keith. The WHILE LOOP is needed because for each loop through it needs to create a unique company name to be used in the insert statement. Each one of those names need to be tied to each of the company group numbers that are in the row_number table. Together they need to be inserted into the table.
For example when run as-is what prints to the screen is:
Company1 -- Company name created dynamically and assigned to variable
50
1
Company2
49
2
Company3
48
3
Company4
47
4
etc... until counter reaches 0 and there are no more records to process
Company50
1
50
A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))