ADD COLUMN, WITH DEFAULT VALUE, TO EXISTING TABLE IN SQL SERVER

Ashish Pandey

Total Post:128

Points:898
Posted by  Ashish Pandey
 1797  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. AVADHESH PATEL

    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!