How to DROP COLUMN in SQL Server

Galaxy Glossary

How do I safely drop a column in SQL Server?

ALTER TABLE ... DROP COLUMN removes one or more columns from an existing SQL Server table.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

What does ALTER TABLE ... DROP COLUMN do?

The command permanently deletes the specified column(s) and their data from a table. Indexes, defaults, and constraints tied only to those columns are removed automatically.

When should I drop a column?

Drop a column when it is obsolete, replaced by a new attribute, or storing redundant data. Always back up data or verify the column is no longer referenced in code, views, or reports.

How do I drop a single column?

Run ALTER TABLE table_name DROP COLUMN column_name; SQL Server removes the column immediately, so wrap it in a transaction if you may need to roll back.

Can I check first?

Use the IF EXISTS modifier (SQL Server 2016+) to avoid errors when the column is already gone: ALTER TABLE ... DROP COLUMN IF EXISTS.

How do I drop multiple columns?

List them comma-separated: ALTER TABLE Products DROP COLUMN discontinued, legacy_price;

Will dependencies break?

Yes. Any view, stored procedure, or application query that references the column will fail. Search your codebase and run sys.sql_expression_dependencies checks before execution.

Best practices for production?

1) Take a backup. 2) Deploy during low-traffic windows. 3) Wrap in a transaction during smoke tests. 4) Use IF EXISTS for idempotent scripts. 5) Update documentation immediately.

Why How to DROP COLUMN in SQL Server is important

How to DROP COLUMN in SQL Server Example Usage


-- Remove an obsolete DiscountCode column from the Orders table
ALTER TABLE Orders
    DROP COLUMN IF EXISTS DiscountCode;

How to DROP COLUMN in SQL Server Syntax


ALTER TABLE <table_name>
    DROP COLUMN [IF EXISTS] <column_name> [, <column_name2> ...] ;

-- Examples in ecommerce context
-- 1. Remove a single column
ALTER TABLE Orders
    DROP COLUMN IF EXISTS DiscountCode;

-- 2. Remove multiple obsolete columns
ALTER TABLE Products
    DROP COLUMN old_price, supplier_code;

Common Mistakes

Frequently Asked Questions (FAQs)

Does DROP COLUMN lock the entire table?

Yes, SQL Server acquires a schema modification lock (SCH-M). Large tables can block concurrent queries. Plan maintenance windows or use partition swapping if possible.

Can I undo a DROP COLUMN?

Not directly. You must restore from backup or re-add the column and repopulate data manually. Always back up first.

Is there a performance impact after dropping columns?

Queries retrieving * will read fewer bytes, potentially improving I/O. Index size may shrink. Rebuild fragmented indexes to reclaim space fully.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.