To drop a column in SQL Server, you can use the ALTER TABLE
statement with the DROP COLUMN
clause. Here’s the syntax:
ALTER TABLE table_name
DROP COLUMN column_name;
Example:
If you have a table named Employees
and you want to drop a column named Age
, you would execute:
ALTER TABLE Employees
DROP COLUMN Age;
Notes:
- You can drop multiple columns at once by separating them with commas:
ALTER TABLE table_name DROP COLUMN column1, column2;
- Make sure that the column is not part of any constraints (such as foreign keys, primary keys, or indexes) before attempting to drop it. You may need to drop or modify constraints first if they reference the column you want to drop.