How do add a column to a table in SQL Server
Loading
How do add a column to a table in SQL Server
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankajkumar PatelRank #181 · 13.4K reputationPosted Aug 13, 2025, 1:41 AM EDT
Hi Kiran Kumar,
You can add a column to an existing table in SQL Server, using the ALTER TABLE statement.
Syntax:
ALTER TABLE table_name ADD column_name data_type [NULL | NOT NULL] [DEFAULT default_value];Example:
Suppose you have a table Employees and you want to add a column named DateOfBirth of type DATE which allows null values:
ALTER TABLE Employees ADD DateOfBirth DATE NULL;Hope this will help you!
Ajay BansodeRank #7,443 · 241 reputationPosted Aug 20, 2025, 3:26 AM EDT
If you want to add a new column in SQL Server, you can use the
ALTER TABLEstatement.Syntax:
ALTER TABLE table_name ADD column_name datatype [NULL | NOT NULL] [DEFAULT default_value];Example 1: Add a nullable column
ALTER TABLE Employees ADD MiddleName VARCHAR(50) NULL;MiddleNameof typeVARCHAR(50)that can containNULL.Example 2: Add a NOT NULL column with default value
ALTER TABLE Employees ADD CreatedDate DATETIME NOT NULL DEFAULT GETDATE();CreatedDatecolumn with default current date/time for existing and new rows.Example 3: Add multiple columns
ALTER TABLE Employees ADD DepartmentID INT NULL, Salary DECIMAL(10,2) NULL;If table already has rows, adding a
NOT NULLcolumn requires a DEFAULT value.Always check dependencies (views, stored procedures) before altering a table in production.
Sandhiya PriyaRank #26 · 43.2K reputationPosted Oct 24, 2025, 12:11 AM EDT
In SQL Server, you can add a new column to an existing table using the
ALTER TABLEstatement.Syntax:
Example 1: Add a simple column
This adds a new column called
Departmentto theEmployeestable.Example 2: Add a column with a default value
Adds a column
IsActivethat:Has data type
BIT(boolean),Cannot be
NULL,Defaults to
1(true) for all existing rows.Example 3: Add multiple columns at once
Adds two columns
JoiningDateandSalaryto the table.Notes:
Adding a
NOT NULLcolumn without a default value will fail if the table already contains data.If you add a
DEFAULTconstraint, existing rows will automatically get the default value.