To Add A Column To An Existing Table In Sql Server we use Alter Statement. The code is below.
1 2 |
Alter table tableName Add columnName datatype [other constraints] |
Example1:
Add a column to the students table named ‘gender’, data type one character of char
1 2 |
Alter Table Students Add gender char(1) |
Example1:
Add a column to the students table named ‘gender’, data type one character of char and default value is ‘F’
1 2 |
Alter Table Students Add gender char(1) default 'F' |