SQL Server Alter Table

How to modify an object with an SQL Server Alter Table query? This ALTER TABLE SQL Server query helps you modify an already existing table. This SQL script allows you to modify the Sales table previously created, by changing the length of the Month Name column. Of course you need to adapt it to your needs.

 

Moreover, the ALTER keyword in SQL allows you to add a column or remove a column.

SQL Server Alter Table

We can see in the script the two lines, one is ALTER TABLE and the other keyword ALTER COLUMN to explicitly change the length of the column.

ALTER TABLE [dbo].[SALES]
ALTER COLUMN [MonthName] NVARCHAR(100);

-- we change the length to 100, initially 50

 

So in the Expert-Only SQL Server tables examples, we have seen how to create a table and now how to modify a table.

 

Be the first to comment

Leave a Reply