so once you have the "N" part of colN value loaded to an int variable, build a while loop to add columns from N+1 maxing out at 50.
while @N <=50
begin
set @N=~N+1
do stuff to add column
end
Looks like you have most of the work done already, the while loop shouldn't be difficult