I create a temp table in SQL. The first columns are always the the same columns and the last two are always the same columns. I create all the other columns dynamically and there could be between 5 - 20 of them.
I will have a variable set to something like this - @var varchar(max) = '110, 120, 130, 140, 150, 155, 156'
This numbers would be the dynamic columns in my temp table.
I need to loop through the variable and if 110 is there place a value in that column, if it is missing place a zero in that column.
Then I need to do this loop again for a new person.