how to add column in sql server

How To Add Column in SQL Server

Sometimes you may need to add column in database table in SQL Server. In this article, we will look at how to add column in SQL Server.


How To Add Column in SQL Server

You can easily add column in SQL server using ALTER TABLE … ADD statement.

Here is the syntax for ALTER TABLE statement to add column in SQL Server

alter table table_name
add column_definition

In the above SQL query, you need to specify the table name, and new column’s full definition.

Also read : How to Duplicate table in SQL Server


For example, here is the SQL query to add column amount to sales table.

alter table sales
add amount int;

You can also specify column constraints while adding a new column. Here is the SQL query to add amount column to sales table, with default value 0.

alter tables sales
add amount int default 0;

Also read : How to Truncate Table in SQL Server


If you want to add multiple columns in SQL server, you need to add their column definitions in a comma-separated manner.

Here is the SQL query to add columns amount and product to sales table.

alter table sales
add amount int,
    product varchar(100);

Leave a Reply

Your email address will not be published. Required fields are marked *