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)
 Constraint error when updating column

Author  Topic 

KHeon
Posting Yak Master

135 Posts

Posted - 2002-10-29 : 08:14:17
Hello!

This is a stupid question I'm sure, and I feel stupid having to ask, but I'm having an issue that just doesn't make sense (to me). I have a USERS table with a column called email_address. On this column is a unique constraint (to ensure no two users have the same email, for obvious reasons).

Problem is, when updating the user, and keeping the email, the update statement is failing (stored procedure) because it's violating the unique constriant. This doesn't make sense to me, why would the unique constriant be violated when the record being updated is the record "violating" the update?

Any insight? Any suggestions for getting around this? The update procedure excepts all data that can be updated, and does an update including all values, I don't split it out per column updated. Is there a better way?

I'm baffled, I haven't had this issue before, in fact with the same setup, the company I work for has always put a unique constraint on the email_address column and never had an issue with updating, not sure why this is different.

Server Info:
WIN2K Server
SQL Server 2000 SP2

Thanks in advance!

Kyle Heon
PixelMEDIA, Inc.
Senior Application Programmer, MCP
kheon@pixelmedia.com

KHeon
Posting Yak Master

135 Posts

Posted - 2002-10-29 : 08:32:56
Nevermind, figured out what I was doing wrong. It's so stupid I would rather not share.

Kyle Heon
PixelMEDIA, Inc.
Senior Application Programmer, MCP
kheon@pixelmedia.com
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-10-29 : 08:36:05
Could be that the data already in the table violates the constraint and is being checked when you update.

Otherwise is there a trigger on the table which is updating the field.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -