UPDATE POLICY_X_INSURED<br />
SET POLICY_X_INSURED.INSURED_EID = '5712'<br />
FROM POLICY_SUPP<br />
WHERE POLICY_SUPP.POLICY_ID = POLICY_X_INSURED.POLICY_ID<br />
AND POLICY_SUPP.LOCATION_CODE = '5752'<br />
AND INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'<br />
<br />
I get back this error<br />
<br />
Server Msg 2601, Level 14, State 3, Line 1<br />
Cannot insert duplicate key row in object 'POLICY_X_INSURED' with unique index 'POLICY_X_INS_PK'.<br />
The statement has been terminated.<br />
<br />
Obviously it has something to do with unique index; the problem is this makes no sense to me, how do i get around this error to update the fields i need to update? The queries should work as I have tested them on a table with the same fields and same data, but I did not put an Index or anything on there...Thanks!<br />
Ok Here is more information...The POLICY_X_INSURED table has two rows, POLICY_ID and INSURED_EID. INSURED_EID is the id that refers back to the entity_id in the entity table. POLICY_X_INSURED and POLICY_SUPP both relate back to the POLICY table by the policy_id. What I am trying to do is update the insured_eid whenever it equals a certain value in the POLICY_SUPP.location_code field. The POLICY_X_INSURED.INSURED_EID field can have multiple rows with the same value as there are only 8 distinct values in the whole table out of over 3000 records. I dont know much about indexes as I have never ran into this problem before. It seems like it would be an easy update. The end result is that the system that this db is attached to will show a different name in the INSURED field of the interface when that particular policy is brought up. Like I said before, i dont know too much about indexes so if more information is needed, let me know. Thanks in advance!<br />
UPDATE POLICY_X_INSURED<br />
SET POLICY_X_INSURED.INSURED_EID = '5712'<br />
FROM POLICY_SUPP<br />
WHERE POLICY_SUPP.POLICY_ID = POLICY_X_INSURED.POLICY_ID<br />
AND POLICY_SUPP.LOCATION_CODE = '5752'<br />
AND INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'<br />
<br />
Why do you have these?<br />
AND INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'<br />
<br />
You are trying to set insured_Eid=5712 and then you are trying to exclude anything that is NOT equal to insured_EID<>5712 & 72703<br />
<br />
What is Insured_EID is it a primary key?<br />
<br />
Insured_eid refers to an entity table, it is the entity_id. What I am doing in the query is updating where POLICY_SUPP.LOCATION_CODE = '5752'. Out all all of those records, I only want to update the records where INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'. I want to keep those values the same, I guess the first one isnt really necessary, but I didnt think it really mattered...<br />
SET POLICY_X_INSURED.INSURED_EID = '5712'<br />
FROM POLICY_SUPP<br />
WHERE POLICY_SUPP.POLICY_ID = POLICY_X_INSURED.POLICY_ID<br />
AND POLICY_SUPP.LOCATION_CODE = '5752'<br />
AND INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'<br />
<br />
I get back this error<br />
<br />
Server Msg 2601, Level 14, State 3, Line 1<br />
Cannot insert duplicate key row in object 'POLICY_X_INSURED' with unique index 'POLICY_X_INS_PK'.<br />
The statement has been terminated.<br />
<br />
Obviously it has something to do with unique index; the problem is this makes no sense to me, how do i get around this error to update the fields i need to update? The queries should work as I have tested them on a table with the same fields and same data, but I did not put an Index or anything on there...Thanks!<br />
Ok Here is more information...The POLICY_X_INSURED table has two rows, POLICY_ID and INSURED_EID. INSURED_EID is the id that refers back to the entity_id in the entity table. POLICY_X_INSURED and POLICY_SUPP both relate back to the POLICY table by the policy_id. What I am trying to do is update the insured_eid whenever it equals a certain value in the POLICY_SUPP.location_code field. The POLICY_X_INSURED.INSURED_EID field can have multiple rows with the same value as there are only 8 distinct values in the whole table out of over 3000 records. I dont know much about indexes as I have never ran into this problem before. It seems like it would be an easy update. The end result is that the system that this db is attached to will show a different name in the INSURED field of the interface when that particular policy is brought up. Like I said before, i dont know too much about indexes so if more information is needed, let me know. Thanks in advance!<br />
UPDATE POLICY_X_INSURED<br />
SET POLICY_X_INSURED.INSURED_EID = '5712'<br />
FROM POLICY_SUPP<br />
WHERE POLICY_SUPP.POLICY_ID = POLICY_X_INSURED.POLICY_ID<br />
AND POLICY_SUPP.LOCATION_CODE = '5752'<br />
AND INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'<br />
<br />
Why do you have these?<br />
AND INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'<br />
<br />
You are trying to set insured_Eid=5712 and then you are trying to exclude anything that is NOT equal to insured_EID<>5712 & 72703<br />
<br />
What is Insured_EID is it a primary key?<br />
<br />
Insured_eid refers to an entity table, it is the entity_id. What I am doing in the query is updating where POLICY_SUPP.LOCATION_CODE = '5752'. Out all all of those records, I only want to update the records where INSURED_EID <>'5712'<br />
AND INSURED_EID <>'72703'. I want to keep those values the same, I guess the first one isnt really necessary, but I didnt think it really mattered...<br />