Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server 2016 (13.x) and later
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL database in Microsoft Fabric
This article describes how to delete table columns in SQL Server using SQL Server Management Studio (SSMS) or Transact-SQL.
Caution
When you delete a column from a table, the column and all the data it contains are deleted.
You can't delete a column that has a CHECK
constraint. You must first delete the constraint.
You can't delete a column that has PRIMARY KEY
or FOREIGN KEY
constraints or other dependencies except when using the Table Designer in SSMS. When using Object Explorer in SSMS or Transact-SQL, you must first remove all dependencies on the column.
Requires ALTER
permission on the table.
You can delete columns in SSMS using Object Explorer or Table Designer.
The following steps explain how to delete columns with Object Explorer in SSMS:
Connect to an instance of Database Engine.
In Object Explorer, locate the table from which you want to delete columns, and expand the table to expose the column names.
Right-click the column that you want to delete, and choose Delete.
In the Delete Object dialog box, select OK.
If the column contains constraints or other dependencies, an error message displays in the Delete Object dialog box. Resolve the error by deleting the referenced constraints.
The following steps explain how to delete columns with Table Designer in SSMS:
In Object Explorer, right-click the table from which you want to delete columns and choose Design.
Right-click the column you want to delete and choose Delete Column from the shortcut menu.
If the column participates in a relationship (FOREIGN KEY
or PRIMARY KEY
), a message prompts you to confirm the deletion of the selected columns and their relationships. Choose Yes.
You can delete columns using Transact-SQL in SSMS, Azure Data Studio, or command-line tools such as the sqlcmd utility.
The following example shows you how to delete a column column_b
from table dbo.doc_exb
. The table and column must already exist.
ALTER TABLE dbo.doc_exb DROP COLUMN column_b;
GO
If the column contains constraints or other dependencies, an error message is returned. Resolve the error by deleting the referenced constraints.
For more examples, see ALTER TABLE.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Design a Performant Data Model in Azure SQL Database with Azure Data Studio - Training
Learn how to create a data model, tables, indexes, constraints, and use data types with Azure data studio.
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Documentation
Add Columns to a Table (Database Engine) - SQL Server
Learn how to add columns to an existing table in SQL Server and Azure SQL platforms by using SQL Server Management Studio or Transact-SQL.
This article shows you how to modify columns using SQL Server Management Studio and Transact-SQL.
Rename columns (Database Engine) - SQL Server
Learn how to rename a table column in the SQL Server Database Engine with SQL Server Management Studio or Transact-SQL.