473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Update Query Help!!

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
2 1551
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
Thanks for your help! And yeah I agree about the underscores and
periods naming convention. Boo for them!!

Shelley

Sep 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kunal | last post by:
Hi, I need some help on writing an update query to update "UnitsSold" field in Products Table whenever I save a transaction. The transaction may contain several "Subtransactions", one for each...
10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
1
by: Wayne | last post by:
I've created a form that has many option boxes to help users choose items (I need option boxes vs. combo boxes because they can choose multiple items per category). I've created an update query...
9
by: DP | last post by:
hi., i've got 3 tables, customer, film and filmrental. i've got a customer form, with a sub form at the bottom, which is a film rental subform. i've created an update query, which when a...
0
by: DP | last post by:
hi, i;ve created an update query, which WORKS!!, i've got an update to check a checkbox in a film table, and i've got another update query to uncheck a checkbox, when a record is deleted. ...
4
by: jofo | last post by:
Hello all, I have project form and an hours form and related tables for each. The project table has a status flag to determine if the project is open or closed. When a user enters hours on a...
1
by: csgraham74 | last post by:
Hi Guys, I was wondering if someone could help me with an access query. I basicallly have two tables A & B Im table A there are numerous records with Fields1 & fields 2 I want to use...
4
by: slavisa | last post by:
Im having trouble with updating my 1 table with the information from another! I have a table with 6 fields. Code(pk), Name, Title, Address, State, city, zip the table is called Info. Now...
1
by: cmorga23 | last post by:
How do I combine the following two update query's???? Example: UPDATE py_per_stu_email SET py_eml_un = (SELECT py_email_un FROM master WHERE master.id = py_per_stu_email.id) Where py_eml_un ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.