• Doesn't need to use a cursor, it can be replaced by:

    SELECT @InsertQuery = @InsertQuery + column_name + ',' from ##Temp_Generate

    Hope Jeff M doesn't see this 😉