Delete columns from a table

Applies to: SQL Server 2016 (13.x) and later Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW)

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.

Limitations and restrictions

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.

Permissions

Requires ALTER permission on the table.

Delete columns using Object Explorer

The following steps explain how to delete columns with Object Explorer in SSMS:

  1. Connect to an instance of Database Engine.
  2. In Object Explorer, locate the table from which you want to delete columns, and expand the table to expose the column names.
  3. Right-click the column that you want to delete, and choose Delete.
  4. In the Delete Object dialog box, click 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.

Delete columns using Table Designer

The following steps explain how to delete columns with Table Designer in SSMS:

  1. In Object Explorer, right-click the table from which you want to delete columns and choose Design.
  2. Right-click the column you want to delete and choose Delete Column from the shortcut menu.
  3. 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.

Delete columns using Transact-SQL

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.

ALTER TABLE dbo.doc_exb DROP COLUMN column_b;
GO

If the column contains constraints or other dependencies, an error message will be returned. Resolve the error by deleting the referenced constraints.

For more examples, see ALTER TABLE (Transact-SQL).

Next steps

For more information about altering tables and related tools, see the following articles: