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.
| Author |
Topic |
|
shamasm
Starting Member
11 Posts |
Posted - 2011-11-17 : 06:18:45
|
| Msg 2627, Level 14, State 1, Procedure spElOutAdtStatusInsert_net_ls, Line 116Violation of PRIMARY KEY constraint 'PK_el_out_adt_status_ls'. Cannot insert duplicate key in object 'dbo.el_out_adt_status_ls'. The duplicate key value is (01, 1, 2).The statement has been terminated.I am getting this error while I am trying to insert the data in the table el_out_adt_status_ls , but no duplicate data is passed.Mahajabeen shama m |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-17 : 06:37:08
|
| Are you sure? Could be duplicate with data that is already in the table or a duplicate in the data you are inserting.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
shamasm
Starting Member
11 Posts |
Posted - 2011-11-17 : 06:41:51
|
| ya i am sure .. Only two records are there. |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2011-11-17 : 06:48:03
|
| Delete the records from table and then insert the new records.PBUH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-21 : 03:01:25
|
quote: Originally posted by shamasm ya i am sure .. Only two records are there.
Can you post the table structure, existing data and the INSERT staement that you are using? Also is there a trigger defined on this table that insert some data to other tables?MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-21 : 03:08:22
|
quote: Originally posted by shamasm Msg 2627, Level 14, State 1, Procedure spElOutAdtStatusInsert_net_ls, Line 116Violation of PRIMARY KEY constraint 'PK_el_out_adt_status_ls'. Cannot insert duplicate key in object 'dbo.el_out_adt_status_ls'. The duplicate key value is (01, 1, 2).The statement has been terminated.I am getting this error while I am trying to insert the data in the table el_out_adt_status_ls , but no duplicate data is passed.Mahajabeen shama m
can you add a condition like below to insert statementINSERT INTO dbo.el_out_adt_status_lsyour select query hereWHERE NOT EXISTS(SELECT 1 FROM dbo.el_out_adt_status_lsWHERE yourprimarykeycolumn= yourselectcolumncontainingpkvalue) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|