Changed to a procedural rather than set based approach because it doesn't lead to truncation of the printed commands and makes it much clearerwhere errors occurred should they happen.
Added comment re: @printCommandsOnly. Also forgot to mention in last comment that I fixed a horrible reversion of the is_nullable value when executing the ALTER COLUMN. Moral of the story: never copy and paste any code directly from StackOverflow without going over it with a fine toothed comb.