By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,838 Members | 2,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,838 IT Pros & Developers. It's quick & easy.

Update Query Help!!

P: n/a
I ran the following update query in Sql Server 8.0:

update _SMDBA_._CUSTOMER_
set _SMDBA_._CUSTOMER_.client = dbo.results.adid
from _SMDBA_._CUSTOMER_, dbo.results
where _SMDBA_._CUSTOMER_.client = dbo.results.clientid;

I got the following error:
Server: Msg 2627, Level 14, State 2, Line 1
Violation of UNIQUE KEY constraint 'UQ_CUSTOMER_CLIENT'. Cannot insert
duplicate key in object '_CUSTOMER_'.
The statement has been terminated.

Shouldn't the update query update the records that match in the
dbo.results table? I'm not appending data, i'm updating...I don't
understand why I'm getting this error! Any help is much appreciated!!

Shelley

Sep 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Shelley,

Aparently, there is a unique constraint with _CUSTOMER_.client in its
definition. There probably is a unique constraint on the client column.
You are updating this key column. If the results table contains
duplicates in the adid column, then this would create duplicates in the
_CUSTOMER_.client column which are disallowed by the constraint.

By the way: I feel sorry for the person that has to maintain this
database because your schema and table names are very hard to read with
all the confusing underscores. But I guess that is just my personal
opinion.

Gert-Jan
sbowman wrote:
>
I ran the following update query in Sql Server 8.0:

update _SMDBA_._CUSTOMER_
set _SMDBA_._CUSTOMER_.client = dbo.results.adid
from _SMDBA_._CUSTOMER_, dbo.results
where _SMDBA_._CUSTOMER_.client = dbo.results.clientid;

I got the following error:
Server: Msg 2627, Level 14, State 2, Line 1
Violation of UNIQUE KEY constraint 'UQ_CUSTOMER_CLIENT'. Cannot insert
duplicate key in object '_CUSTOMER_'.
The statement has been terminated.

Shouldn't the update query update the records that match in the
dbo.results table? I'm not appending data, i'm updating...I don't
understand why I'm getting this error! Any help is much appreciated!!

Shelley
Sep 26 '06 #2

P: n/a
Thanks for your help! And yeah I agree about the underscores and
periods naming convention. Boo for them!!

Shelley

Sep 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.