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
 General SQL Server Forums
 New to SQL Server Programming
 update statement error

Author  Topic 

qutesanju
Posting Yak Master

193 Posts

Posted - 2010-08-16 : 05:15:58
hi experts
I'm firing an update statement in a table
UPDATE [dbo].[LOC_XREF]
set
[KC_LOC_XREF_MES_MACHI_CHR] = '2028BILGNM09'
WHERE [ENTY_KEY] ='102166793'

however i'm getting an error as
Cannot insert duplicate key row in object 'dbo.LOC_XREF' with unique index 'ix_LOC_XREF_1'.


how to resolve this issue?

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-16 : 05:22:08
This update statement is about to change data that combination is already exists.
and that is not possible because with that key column unique index is created.

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

qutesanju
Posting Yak Master

193 Posts

Posted - 2010-08-16 : 07:34:25
i deleted that entry completely and tried inserting fresh one
but it says
Cannot insert duplicate key row in object 'dbo.KC_LOC_XREF' with unique index 'ix_kc_loc_xef_1'.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-08-16 : 07:43:45
What's the definition of the unique index ix_kc_loc_xef_1?
How many rows will that update affect?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

qutesanju
Posting Yak Master

193 Posts

Posted - 2010-08-16 : 08:46:22
index name ix_kc_loc_xef_1 is nonclustered, unique located on PRIMARY
and index keys are
LOC_XREF_MES_DATAB_CHR, LOC_XREF_MES_MACHI_AREA_CHR, LOC_XREF_MES_MACHI_CHR, LOC_XREF_MES_SYSTE_CHR
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-08-16 : 09:29:41
How many rows will that update affect?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

qutesanju
Posting Yak Master

193 Posts

Posted - 2010-08-16 : 11:34:31
for search criteria this shuld update only one row
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-08-16 : 11:40:18
Do you understand about unique indexes and Alternate keys?

Runs this...


SELECT LOC_XREF_MES_DATAB_CHR, LOC_XREF_MES_MACHI_AREA_CHR, LOC_XREF_MES_MACHI_CHR, LOC_XREF_MES_SYSTE_CHR
FROM [dbo].[LOC_XREF]
WHERE [ENTY_KEY] ='102166793'




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -