In this step by step SQL Tutorial I will show you how to use ALTER TABLE DROP COLUMN statement. For the purpose of this tutorial I will use SQL Server 2012.
Other Versions of SQL Server:
- SQL Server 2012
- This blog post has been written using SQL Server 2012
- SQL Server 2008 / R2
- The examples we used should work in SQL Server 2008 and R2
- SQL Server 2005
- We suspect that this will work in SQL Server 2005 as well
Who is it for?
- People who would like to learn basics of using Alter Table Drop Column
- Those who are preparing for Microsoft certifications and need to cover this topic.
We can use ALTER TABLE to update the schema of an existing table.
ALTER TABLE statement
ALTER TABLE table_name
DROP COLUMN column_name
In the Object Explorer I open required database in this case it is AdventureWorksDW2012 then I expand Tables folder and find table which will use to ALTER TABLE DROP COLUMN example. In this case it is dbo.Customer table.
I retrieve all field from dbo.DimCustomer to check which field I want to drop. In this case I will remove Title.
I type my code and run the query. In Messages window I get the information that my query was run successful.
I select all fields from dbo.DimCustomer and I can see that my Title field is not displayed.
I hope that help