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)
 update existing rows with default value

Author  Topic 

vipinM
Starting Member

9 Posts

Posted - 2007-08-20 : 03:25:44
i have set default value on existing column of the table
but that set value does not effect on the existing rows.
Plz give me right way to update the existing row with default value.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 04:20:46
UPDATE Table1 SET Col1 = <DEFAULT VALUE> WHERE Col1 IS NULL



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

vipinM
Starting Member

9 Posts

Posted - 2007-08-20 : 09:44:03
I don't want update table.I require some solution through either
constraint or default.Is there any option in either
constraint or default to update automatically into table.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 09:46:47
You should have used the option to fill the default value on existing records WHEN creating the default value.
Now it is to late.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-20 : 12:54:53
Run the foll. script to add a default value to a column:


Alter table YourTable add constraint cnDefColumn5 default 0 for Column5



Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -