473,406 Members | 2,356 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,406 software developers and data experts.

SQL Duplicate Error

SJ
Hi!

I am trying to do a simple udpate on a table and I am getting the
error:

"Cannot insert duplicate key row in object 'UserInfo' with unique
index 'UserInfo_Login'.The statement has been terminated."

Here is the command I am trying to run
---
USE Deve2_SITE

update UserInfo set tp_Login=N'DEV2\sam', tp*************@test.com',
tp_Title=N'Samson, Sammy'
WHERE (tp_Login=N'DEV\sam')
--

Any ideas?

Jun 20 '07 #1
4 4959
What it seems to be saying is that there is already a row in the table
with the value N'DEV2\sam', and the index UserInfo_Login has a unique
constraint that does not permit duplicates. However it is possible
the index has multiple columns. To know exactly you would need to
know the details of the definition of the index UserInfo_Login on the
table UserInfo. You could find that out by running:

EXEC sp_helpindex Deve2_SITE..UserInfo

Roy Harvey
Beacon Falls, CT

On Wed, 20 Jun 2007 09:51:15 -0700, SJ <sj******@gmail.comwrote:
>Hi!

I am trying to do a simple udpate on a table and I am getting the
error:

"Cannot insert duplicate key row in object 'UserInfo' with unique
index 'UserInfo_Login'.The statement has been terminated."

Here is the command I am trying to run
---
USE Deve2_SITE

update UserInfo set tp_Login=N'DEV2\sam', tp*************@test.com',
tp_Title=N'Samson, Sammy'
WHERE (tp_Login=N'DEV\sam')
Jun 20 '07 #2
On Jun 20, 11:51 am, SJ <sjour...@gmail.comwrote:
Hi!

I am trying to do a simple udpate on a table and I am getting the
error:

"Cannot insert duplicate key row in object 'UserInfo' with unique
index 'UserInfo_Login'.The statement has been terminated."

Here is the command I am trying to run
---
USE Deve2_SITE

update UserInfo set tp_Login=N'DEV2\sam', tp_Email=N't...@test.com',
tp_Title=N'Samson, Sammy'
WHERE (tp_Login=N'DEV\sam')
--

Any ideas?
In addition to Roy's advice, do you have triggers on your table?

http://sqlserver-tips.blogspot.com/

Jun 20 '07 #3
SJ
On Jun 20, 1:42 pm, Alex Kuznetsov <AK_TIREDOFS...@hotmail.COMwrote:
On Jun 20, 11:51 am, SJ <sjour...@gmail.comwrote:


Hi!
I am trying to do a simple udpate on a table and I am getting the
error:
"Cannot insert duplicate key row in object 'UserInfo' with unique
index 'UserInfo_Login'.The statement has been terminated."
Here is the command I am trying to run
---
USE Deve2_SITE
update UserInfo set tp_Login=N'DEV2\sam', tp_Email=N't...@test.com',
tp_Title=N'Samson, Sammy'
WHERE (tp_Login=N'DEV\sam')
--
Any ideas?

In addition to Roy's advice, do you have triggers on your table?

http://sqlserver-tips.blogspot.com/- Hide quoted text -

- Show quoted text -
Thanks all. I guess i dont know what an index is. And why an update
would matter. This is the result of the EXEC command:

UserInfo_FullText nonclustered, unique located on PRIMARY tp_GUID
UserInfo_Login nonclustered, unique located on PRIMARY tp_SiteID,
tp_Login, tp_Deleted
UserInfo_PK clustered, unique, primary key located on PRIMARY
tp_SiteID, tp_ID
UserInfo_SID nonclustered, unique located on PRIMARY tp_SiteID,
tp_SystemID

ANy ideas? Why is an update command doing an insert (that is probably
a dumb question)

Jun 20 '07 #4
>UserInfo_Login nonclustered, unique located on PRIMARY tp_SiteID,
>tp_Login, tp_Deleted
OK, the UNIQUE contraint is on three columns, the combination of
tp_SiteID, tp_Login and tp_Deleted.

The UPDATE command is not doing an INSERT, but it is changing the
value of the column so that the combination of those three columns
conflicts with data already in the table - it woud violate the UNIQUE
contraint.

If you run the query:

SELECT *
FROM Deve2_SITE..UserInfo
WHERE tp_Login IN ( N'DEV\sam', N'DEV2\sam')
ORDER BY tp_Login, tp_SiteID, tp_Deleted

That will show the rows that are in conflict. What you are looking
for is that there is already DEV2\sam for at least one matching pair
of tp_SiteID/tp_Deleted values.

Hope that helps.

Roy Harvey
Beacon Falls, CT

On Wed, 20 Jun 2007 11:55:41 -0700, SJ <sj******@gmail.comwrote:
>On Jun 20, 1:42 pm, Alex Kuznetsov <AK_TIREDOFS...@hotmail.COMwrote:
>On Jun 20, 11:51 am, SJ <sjour...@gmail.comwrote:
Hi!
I am trying to do a simple udpate on a table and I am getting the
error:
"Cannot insert duplicate key row in object 'UserInfo' with unique
index 'UserInfo_Login'.The statement has been terminated."
Here is the command I am trying to run
---
USE Deve2_SITE
update UserInfo set tp_Login=N'DEV2\sam', tp_Email=N't...@test.com',
tp_Title=N'Samson, Sammy'
WHERE (tp_Login=N'DEV\sam')
--
Any ideas?

In addition to Roy's advice, do you have triggers on your table?

http://sqlserver-tips.blogspot.com/- Hide quoted text -

- Show quoted text -

Thanks all. I guess i dont know what an index is. And why an update
would matter. This is the result of the EXEC command:

UserInfo_FullText nonclustered, unique located on PRIMARY tp_GUID
UserInfo_Login nonclustered, unique located on PRIMARY tp_SiteID,
tp_Login, tp_Deleted
UserInfo_PK clustered, unique, primary key located on PRIMARY
tp_SiteID, tp_ID
UserInfo_SID nonclustered, unique located on PRIMARY tp_SiteID,
tp_SystemID

ANy ideas? Why is an update command doing an insert (that is probably
a dumb question)
Jun 20 '07 #5

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

Similar topics

3
by: Mohammed Mazid | last post by:
Hi, Basically I have a problem with registering to my quiz system. I had borrowed some code from an existing program but I just do not know why it doesn't work. If (txtUsername = "" Or...
0
by: Gary Lundquest | last post by:
I have an application with MS Access 2000 as the front end and MySQL as the back end. All was well until I upgraded the MySQL (Linux) server. The Problem: I insert data into a cumulative table....
1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
2
by: stranger | last post by:
My database is set up so people can input parts orders. Sometimes they order the same parts on a monthly basis. I want to be able to duplicate past parts orders and have it pasted in with a new...
1
by: Mike Hunter | last post by:
(Please CC me on any replies as I'm not on the list) Hi, After a recent power failure, a program that uses a pgsql backend (netdisco) started to send me nastygrams. I tried the author's...
1
by: Joseph Chase | last post by:
I am running version 4.1.13a-log on a Mac XServe. How can I receive a 'duplicate entry' error for an UPDATE? An update isn't creating an entry, so why this error message? ...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
5
by: baur79 | last post by:
Hi guys i try to run this code in loop and to pass even the entry is duplicated def email_insert_in_db(email): sql="INSERT INTO emails (email) values ('%s') "%(email)...
6
by: Dave | last post by:
I really don't like the users getting an unhandled expception page, and I'm still to new with ASP.Net and C#. So please accept my appology for the 2 part question. SqlException (0x80131904) ...
0
by: Narendra Gc | last post by:
Hi... I am looking after a lan . I am i am not able to access one particular system , by another one particular system. But from these computers i can access all other systems in my lan and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.