473,587 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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'Sams on, Sammy'
WHERE (tp_Login=N'DEV \sam')
--

Any ideas?

Jun 20 '07 #1
4 4970
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..Use rInfo

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'Sam son, 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'Sams on, 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.COMwro te:
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'Sams on, 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_FullTe xt 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_Log in 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..Use rInfo
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.COMwro te:
>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'Sams on, 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_FullT ext nonclustered, unique located on PRIMARY tp_GUID
UserInfo_Log in 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
3943
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 txtPassword = "") Or (txtFirstName = "" Or txtLastName = "") Then MsgBox "Please complete all the fields", vbCritical = vbOKOnly, "Incomplete Login...
0
3091
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. Before when I did this, and there were duplicate entries, the duplicate entries were rejected and I got a return code with the number of affected...
1
838
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 to completion. Version 4 seems to STOP when it encounters a duplicate entry, so that the records before the duplicate are inserted and the records...
2
3225
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 primary key. My first attempt seemed to work(minus a few Microsoft glitches). I used a "duplicate" command button at first. This made a copy of the...
1
6669
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 suggestion of running a VACUUM FULL ANALYZE VERBOSE;, but it still sends me the messages. The data in the database isn't too important, i.e. I'm willing...
1
6424
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? ____________________________________________________ 060427 11:57:23 Slave SQL thread initialized, starting replication in log 'kiosk1-bin.000006' at position 7233,...
8
3921
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 this line: Set rs = db.OpenRecordset("SELECT ID FROM Contacts WHERE (" & sWhere & ");") Contacts being the main table. I am using access 2003...
5
22981
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) db=_mysql.connect(host = "localhost", user = db_user, passwd = db_pass, db = db_name)
6
11996
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) 1.) Is an "Cannot insert duplicate key row" exception from a FormView returned as part of the ItemInserting or ItemInserted event? 2.) What is...
0
2361
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 vice- versa.only the communication between these two computers is affected. Error is " A duplicate name exists on the network " I searched...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.