How to DROP multiple columns with a single ALTER TABLE statement in SQL Server?

后端 未结 13 1148
星月不相逢
星月不相逢 2020-12-22 18:17

I would like to write a single SQL command to drop multiple columns from a single table in one ALTER TABLE statement.

From MSDN\'s ALTER TABLE documenta

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 18:45

    If it is just single column to delete the below syntax works

    ALTER TABLE tablename DROP COLUMN column1;

    For deleting multiple columns, using the DROP COLUMN doesnot work, the below syntax works

    ALTER TABLE tablename DROP (column1, column2, column3......);

提交回复
热议问题