Loading ...

When we want to add,delete and delete the coloum in the exiting table then we use Alter Command. | CodeAsp.Net

Alter table command In MSSQL

 /5
0 (0votes)

When we want to add,delete and delete the coloum in the exiting table then we use Alter Command.

Add a Column in a Table
Syntex:

ALTER TABLE tableName
ADD columnname datatype

Example:

ALTER TABLE Emp
ADD City Varchar(500) null

Add More than one colum at a time:

ALTER TABLE Emp
ADD (City Varchar(500) null,Country Varchar(500) null)

Delete a colum from the Table
Syntex:

ALTER TABLE tableName
DROP COLUMN columnname

Example:

ALTER TABLE Emp
DROP COLUMN City

Change datatype of Column.
Syntex:

ALTER TABLE tableName
Alter COLUMN columnname datatype

Example:

ALTER TABLE Emp
Alter COLUMN City nvarchar(400)

Comments (no comments yet)

  • :*
  • :*
  • :
 *

Top Posts