Add column, with default value, to existing table in SQL Server

Total Post:128

Points:898
 2147  View(s)
Ratings:
Rate this:
Hi Everyone!

How do you add a column, with a default value, to an existing table in SQL Server 2000/2005?

Thanks in advance! 
  1. Post:604

    Points:4228
    Re: Add column, with default value, to existing table in SQL Server

    Hi Ashish!


    You can try as below

    ALTER TABLE {TABLENAME} 
    ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} 
    CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}

    I hope it resolve your problem

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!