SQL Server 2012 – How to Add a Column to an Existing Table

sql-server-2012

I'm wanting the best way to add a column to an existing table in my database. I'm using SQL Server 2012. I don't want the data that is in the table to be affected, I just want to add a new column that has a default value of NULL. The only ways I'm aware of for adding a new column is by using:

ALTER TABLE dbo.myTable ADD newColumn VARCHAR(20) NULL;

and the other way of adding a new column is by going into SQL Server Management Studio, bringing up the Design for the table I want to update, and adding the new column's information to the design.

Best Answer

There is no "BEST" way to add a column. There is only one way - using the T-SQL command. What do you think happens when you use SSMS table design? it's just a way to simplify tasks for those who don't know the syntax. When you click OK, SSMS generates the ALTER TABLE statement and executes it for you.