Help with SQL Statement error !!!

  • Can anyone help me out .. not really sure where to start looking on this one. this statement below works against one table, but not another with similar settings:

    The SQL statement is:

     INSERT INTO tblMACD (Ebond_ID,Assigned_to,Ticket_Time,Analog_Line,Comments,UserID,Date,Date_Complete,Closed,Site_Number,Vantive_ID,SLA,Description_or_Work,Created_By,Completed_By,Vantive_SLA_Due_Date,Vantive_Open_Date_SLA,Expedite)

    VALUES

    ('1000000025','979-123-4567','0','0',' test','wenjie.shi','11/22/2004 11:00:00 AM','11/22/2004 11:00:00 AM','Close','AS30NJ0006','NA','1','test','Wen Shi','979-123-4567','11/22/2004 01:00:00 PM','11/22/2004 11:00:00 AM','0')

     The Error is:

    Cannot insert duplicate key row in object 'tblMACD' with unique index 'idx_tblmacd_1'. Severity 14, State 3, Procedure 'SIEBWEBDEV1 null', Line 1

     The tblMACD table has a field ID, which should be automatically created and inserted into the table whenever a new record is inserted. The table tblMACDBilling has the same setup and is working fine, but not this table.

  • I would start by looking at the table you are inserting into and looking at the structure of the unique index.

    One of the items in your insert statement already exists in the table and there can't be duplicates.

    Let us know what the unique key is and we can help you more from that.

    Tom

     

  • So far I can see that tblMACD has a unique  index called idx_tblmacd_1 based on column Vantive_ID that tblMACDBilling does not have

  • If Vantive_ID has a unique index on it, meaning it can't share a value with any other row in the table.  You are trying to insert a '1' in that field.

    Do a select from tblmacd where vantive_ID = '1'

    That is the conflicting row.

    Tom

  • Thank you so much for pointing me in the right direction.

    The table does have a unique index and it is based on column Vantive_ID and does not allow duplicates. they are trying to insert a duplicate value.

    Thanks again and Happy Turkey Day!!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply