Delete Columns from a Table
This topic describes how to delete table columns in SQL Server 2017 by using SQL Server Management Studio or Transact-SQL.
When you delete a column from a table, it and all the data it contains are deleted.
In This Topic
Before you begin:
To delete a column from a table, using:
Before You Begin
Limitations and Restrictions
You cannot delete a column that has a CHECK constraint. You must first delete the constraint.
You cannot delete a column that has PRIMARY KEY or FOREIGN KEY constraints or other dependencies except when using the Table Designer. When using Object Explorer or Transact-SQL, you must first remove all dependencies on the column.
Requires ALTER permission on the table.
Using SQL Server Management Studio
To delete columns by using Object Explorer
- In Object Explorer, connect to an instance of Database Engine.
- In Object Explorer, locate the table from which you want to delete columns, and expand to expose the column names.
- Right-click the column that you want to delete, and choose Delete.
- In Delete Object dialog box, click OK.
If the column contains constraints or other dependencies, an error message will display in the Delete Object dialog box. Resolve the error by deleting the referenced constraints.
To delete columns by using Table Designer
- 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.
To delete columns
The following example shows you how to delete a column.
ALTER TABLE dbo.doc_exb DROP COLUMN column_b;
If the column contains constraints or other dependencies, an error message will be returned. Resolve the error by deleting the referenced constraints.
For additional examples, see ALTER TABLE (Transact-SQL).