IMG-LOGO

How to remove column in sql server using query?

andy - 20 Oct, 2019 2484 Views 0 Comment

In this article, we are going to learn how to remove a table column in SQL Server using the SQL query. To delete a column we can need to use the keyword ALTER to modify the table that we want to delete the column. Then we can use the keyword DROP to remove the column.

Here is the SQL query to remove a column of an existing table in SQL Server.

ALTER TABLE dbo.table_name DROP COLUMN column_name;
One thing to remember, if there is a constraint against the column, you will receive an error message. In order to fix this issue, you need to remove the constraint first.

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.

Related Articles

How to restore database using SQL query in TSQL?

If you have a database backup bak file extension and want to restore it using SQL query You can use the built in RESTORE DATABASE function Remember in order to be able to restore a database successfully You need to ...

How to get all table sizes in TSQL?

To get the information about how much space or size used by tables You can retrieve the size information by linking multiple tables in sys tables There are two tables that hold this information The first one is the sys ...