When you create a database table, you specify all columns along with their data types. Once created, there’s not normally any intention of changing these data types. After all, whoever designed the schema would have put a lot of thought into what data type each and every column should accept.
However, we all know that things can change. Despite our best efforts at trying to foresee every possible scenario that may hit our database, sometimes that’s not enough.
So what do we do if we need to use Transact-SQL to change the data type of a column in SQL Server?
We use the ALTER TABLE
statement to change it of course.