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
 General SQL Server Forums
 New to SQL Server Programming
 how to add zero to all records

Author  Topic 

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-10-08 : 15:10:03
Hi
I have added a new column(seq) in sql to an existing table(Report)which already has 100000 records in it
now I am trying to make the new column(seq) as a constraint with the below autogenerated code and it fails

ALTER TABLE [Request]
ADD CONSTRAINT [REPORT_Seq] DEFAULT ((0)) FOR [Seq]
GO

Fails with the below error message
Msg 1781 column has already a DEFAULT bound to it

can someone assist me to debug this

Thanks
Vamsi

X002548
Not Just a Number

15586 Posts

Posted - 2010-10-08 : 15:17:24
ummmm....isn't that self explanatory?


Scrript the table and check it out, or do sp_help [Request]




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx





Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-10-08 : 15:18:19
and do we really need to go back to the discussion that 0 <> (null)

did you know that (null) <> (null)????



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx





Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-10-08 : 15:32:08
The SQL I had in my post is autogenerated from our testing database
and when I run the same script on the stage I get the error

I need another way to do this manually
where I can populate all the values of the newly created column to '0' and then try to add the constraint
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-10-08 : 18:30:16
UPDATE Request
SET Seq = 0
WHERE Seq IS NULL



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -