Home > DeveloperSection > Forums > Add a column of zeros to table sql server
Chintoo Semi

Total Post:135

Points:947
Posted on    May-04-2013 2:02 AM

 C# C# 
Ratings:


 1 Reply(s)
 682  View(s)
Rate this:
Hi Everyone!

I have a table in sql server, but want to add a extra column full of zeros

What would be the best approach to do this

att1 att2
---------
1.0   5.8
2.7   3.8
5.1   6.8
becomes

att1 att2  extra
----------------
1.0   5.8   0.0
2.7   3.8   0.0
5.1   6.8   0.0


Thanks in advance!


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-04-2013 8:57 AM

Hi Chintoo!

you can try as following approach 

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

I hope it resolve your problem!

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

Follow MindStick