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.
- using ALTER statement using:
- ALTER TABLE table_name
- ADD column_name datatype;
Similarly, we can drop a column using following code.
- ALTER TABLE table_name
- DROP COLUMN column_name;
We can change the data type of an existing column.
- ALTER TABLE table_name
- ALTER COLUMN column_name datatype;
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.

Hadshana KamalanathanPosted Jul 15, 2018, 9:17 PM
Good Article,Thank you for sharing information
Hiten PandyaPosted Jan 24, 2018, 4:09 AM
Thank you sir for sharing nice article
Naresh SinghalPosted Jan 22, 2018, 11:38 PM
Excellent.................