Friday 20 June 2014

Add new column in existing table with default value in sql server

To perform this process just follow this,


Syntex:

Alter table <table_Name>
Add column <column_Name> null/not null default


Query:

let say user table has column username,password. now i am adding createdon(date), to achieve this

Alter table user
add column createdon null default(getdate())


Result:
along with existing data new column will added as well as value also.

happy coding :)

No comments:

Post a Comment