Delete data columns
The data columns that are built, wrong, or duplicated in the development or production process need to be deleted.
Use the SSMS database management tool to delete data column mode one
1. Open database--Select data Table-"Expand Data Sheet-" Expand Data Column-"Select the data column to delete-" Right click-"SELECT Delete-" in the Pop-up box click OK.
Way Two
1. Open Database-"Open data Sheet-" Right click-"SELECT Design.
2, in the Design view window-"Select the data column to delete-" Right click-"SELECT Delete-" Click the Save button (or Ctrl+s).
Delete a single data column by using a T-SQL script to delete a data column
Syntax: ALTER TABLE data name. dbo. Table name drop column name;
Example: ALTER TABLE [TESTSS].DBO. [Test1] Drop column height3;
Delete multiple data columns
Syntax: ALTER TABLE data name. dbo. Table name drop column name 1, column name 2;
Example: ALTER TABLE [TESTSS].DBO. [Test1] Drop column height1,height2;
Delete a data column with default values
Grammar:
BEGIN TRANSACTION
Go
ALTER TABLE data name. dbo. Table name drop constraint constraint name;
Go
ALTER TABLE data name. dbo. Table name drop column name;
Example:
BEGIN TRANSACTION
Go
ALTER TABLE [TESTSS].DBO. [Test1] drop constraint df__test1__testid__151b244e;
Go
ALTER TABLE [TESTSS].DBO. [Test1] Drop column testid;
Summarize
In the development or testing process, the modification of the column is arbitrary operation, once to the production environment, no matter what the data column problems, do not easily modify and delete, if you have to modify and delete, you must first back up and operation.
SQL Server deletes data columns