How to Add or Drop Column by using GUI in SQL Server - SQL Server / T-SQL Tutorial Part 39


You have created table dbo.Customer by using below script in Database TechBrothersIT. 

CREATE TABLE [dbo].[Customer](
    [FName] [varchar](50) NULL,
    [LName] [varchar](30) NULL,
    [Age] [tinyint] NULL,
    [PhoneNumber] [char](9) NULL,
    [DOB] [date] NULL,
    [Gender] [char](1) NULL

You received new requirement.You have to add new column "Address" to table and delete Column "Gender" from Table.


In SSMS, you can use Design window to add columns and drop columns. You can also script the changes to run in other environments such as QA,UAT and Production.

Step 1:
Go to Database and then Tables tab and then find your required table. Right Click on Table and select Design.

How to Add Column or Drop Column in Design Windows in SSMS- SQL Server Tutorial

Step 2: 
Design windows will open, Go ahead at the end and add new column. Provide the Column Name and Data Type and if you would like to allow Null values for it or not.
Add Column to SQL Server Table in Design Mode in SSMS - TSQL Tutorial 

To Delete Column, Choose the Column and Then hit Right Button on your mouse and click Delete Column as shown below.
How to Delete Column in Design Windows from SQL Server Table - T-SQL Tutorial

Now you have two options, if you would like to save the changes to table, Go ahead and hit Save button. If you want to script the changes, Click on Generate Scripts Button so you can use in any environment.
Generate Add or Drop Column Scripts from Design Windows in SSMS - SQL Server Tutorial

Once you hit Generate Change Script Button, Below windows will appear and ask you to save the scripts as shown below. 

Add Column or Drop Column Scripts for SQL Server Table - T-SQL Tutorial 

Video Demo : How to generate Add Column or Drop Column Statement from GUI in SQL