In SQL Add Column is used to add a new column to the existing SQL Server table. In this article, we will show you, How to use the SQL Alter Table Add column statement to add a new column with an example.
For this Sql Server alter table add column demonstration, We are going to use the below-shown Customer table.
SQL Add Column example
In order to add a new column to the existing table, Please use the following syntax
-- SQL Server Add Column ALTER TABLE [Table_Name] ADD [New_Column] Data_Type (Length) NULL | NOT NULL
In this example, we are going to add Sales Column to the existing Customers table
-- SQl Server Add Column Example USE [NewNameDB] GO ALTER TABLE Customers ADD Sales MONEY NULL
From the above code snippet you can see that, we added Sales Column of Money data type, and it will allow NULL Values
From the below screenshot you can see the new column
SQL Add Column using SSMS
If you can access the SQL Management Studio then you can use the following steps to add a new column. Right-click on the Table, and select the Design from the context menu.
Selecting the Design option will open the table in design mode.
Let me add new column called Tax, and the data type that we assigned was Money
Click the Close button will display the pop-up window. Please select the Yes button to save the changed that you made in the design window.
Now you can see the newly added column called the tax.
Thank You for Visiting Our Blog