Home > DeveloperSection > Forums > Alter Table
Jack C
Jack C

Total Post:13

Posted on    September-29-2010 1:44 PM

 MSSQL Server MSSQL Server 

 2 Reply(s)
 1274  View(s)
Rate this:
I have a table which contains 23 columns now due to project requirement I have to add few more columns in the existing table.
Column name like newLocation, oldCityName.
If possible provide me sample of code to add columns in a table.

Thanks in advance

Amit Singh

Total Post:103

Posted on    September-30-2010 1:15 PM

we add the new column in a table by using alter command as
alter table tablename add columnname datatype constraints

alter table tablename add newLocation varchar(30), oldCityName varchar(20)

Uttam Misra

Total Post:125

Posted on    October-03-2010 4:24 AM

To add a column to an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name
 ADD column_name column-definition;

For example:

ALTER TABLE employee
 ADD employee_name  varchar(50);

This will add a column called employee_name to the Employee table.

Don't want to miss updates? Please click the below button!

Follow MindStick