Sql Server Drop multiple columns from a table in a single statement
- Posted by Sqltimes
- On May 21, 2014
- 0 Comments
Quick one today
Sometimes, there is a need to DROP more than one columns from a table. The usual approach of DROPping one column at a time still works. Today we’ll explore the option to DROP multiple columns at the same time using a single ALTER TABLE statement.
It is intuitive this way…
1
2
3
4
5
6
7
8
9
|
-- -- DROP multiple columns using single ALTER TABLE statement -- ALTER TABLE dbo.SampleTable DROP COLUMN Name -- add comments for reason for each column , Age -- 'Age' is not required any more , Date_of_Birth -- 'DoB' is depricated , SSN -- 'SSN' is moved GO |
Hope this helps,
_Sqltimes
0 Comments