Introduction:
In this article we will learn the
queries to remove/drop a single or
multiple columns from the sql server database table.
We can remove the column in two ways, using query or manually( in design of table). In this article
I will explain how to remove columns by using SQL Query.
Note: Here TableName is the name of the table
from where you want to remove the column and ColumnName is the name of the column that you
want to remove.
E.g. alter table Employee drop column empname
Syntax to
drop/remove multiple columns:
alter table TableName drop column ColumnName1, ColumnName2
alter table TableName drop column ColumnName1, ColumnName2
Note: Here TableName is the name of the table from where you want to remove the column
and ColumnName1, ColumnName2 are the name of the columns that
you want to remove.
E.g. alter table Tb_Emp drop column empname, salary
E.g. alter table Tb_Emp drop column empname, salary
Note: When you delete a column from a table then that column and all the
data it contains are deleted from the database and it cannot be rollback. So keep this in mind while executing this query.
0 comments:
Post a Comment