Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 alter table

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2002-06-04 : 19:32:43
How would I alter the following code to insert the value of "0" for each row in column_a.

ALTER TABLE finish ADD column_a BIT NULL

Thanks,
Lane

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-06-04 : 19:49:32
ALTER TABLE finish ADD column_a BIT NULL
go
UPDATE finish SET column_a=0
go

If you set a default it won't work unless the column is not null e.g.

ALTER TABLE finish ADD column_a BIT NOT NULL DEFAULT(0)

HTH
Jasper Smith


Go to Top of Page

olily
Starting Member

37 Posts

Posted - 2002-06-05 : 03:34:08
ALTER TABLE FINISH ADD column_a BIT NULL DEFAULT 0 WITH VALUES

WITH VALUES will populate all the rows in your table with 0.



Go to Top of Page
   

- Advertisement -