Thursday, January 16, 2025
HomeProgrammingHow To Drop Column In SQL Server?

How To Drop Column In SQL Server?

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.
RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x