I have a code that looks something like this
declare @query = '
Alter Table Temp
Add NewColumn int
update Temp
set NewColumn = 100'
exec (@query)
It will give error NewColumn does not exist. But if I run this normally without using @query = '' it runs fine. Also, what is it called when you run the code like this with the @query = ' text ' then exec?