SQL Server 2016 Hosting – HostForLIFE.eu ::Invalid Column Name ‘ABC’ Error While Accessing Newly Added Column

In this blog, we will look into accessing a newly-added column to a table. We can add a new column to an existing table.

Similarly, we can drop a column using following code.

We can change the data type of an existing column.

When we add a new column using ALTER TABLE statement, then try to access immediately in the same batch using SELECT\UPDATE\INSERT statement. It will throw the below error:
This error is because the newly added column will be reflected only after completion of the current batch. To fix it, we can split it into two different batches separated by batch separator [GO].
We can also use dynamic SQL instead of splitting into two batches as shown below.


I attached SQL script and am ending here. I hope this is informative.