I am getting this error when I run this query. The full error is :
Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_infmtx_dat_Transactions'. Cannot insert duplicate key in object 'dbo.infmtx_dat_Transactions'.
The statement has been terminated.
When I looked at infmtx_dat_Transactions it has 5 primary keys:tranid,chgid,chgidagnst,rptpd,trantype.
Is there a way to write a select statement to find out what the duplicates are? Any help is apprecaited. Tom
Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_infmtx_dat_Transactions'. Cannot insert duplicate key in object 'dbo.infmtx_dat_Transactions'.
The statement has been terminated.
When I looked at infmtx_dat_Transactions it has 5 primary keys:tranid,chgid,chgidagnst,rptpd,trantype.
Is there a way to write a select statement to find out what the duplicates are? Any help is apprecaited. Tom
Code:
/*** POST TRANSACTIONS LIVE ***/
INSERT INTO infmtx_dat_Transactions (tranid,chgid,chgidagnst,incnumagnst,rptpd,aid,claimid
,chgsvcpd,trantype,doschg,doscalpd,postdtchg,postdtchgcalpd,postdttran
,postdttrancalpd,depositdt,depositcalpd,cptid,cptcode,cptcomp,billprov
,rendprov,facid,posid,dptid,priminsmne,priminscatid,transcode,crcat
,refprovid,modalid,units,adjunits,patcnt,enccnt,cptcnt,amt,chgallow
,totworkrvu,totfacrvu,denial,curresponsible,curbal,curinsmne
,curopenbalflag,curcreditbalflag,denyflag,denycode,denydate,feetypeid )
SELECT
trn.tran_id
,trn.chg_id
,chg.chgidagnst
,chg.incnumagnst
,trn.rptpd
,trn.acctid
,chg.claimid
,chg.rptpd
,tcd.trantype
,chg.doschg
,chg.doscalpd
,chg.postdtchg
,chg.postdtchgcalpd
,trn.tranpostdt
,trn.tranpostpd
,trn.pmtdate
,trn.pmtpd
,chg.cptid
,chg.cptcode
,chg.cptcomp
,chg.billprov
,chg.rendprov
,chg.facid
,chg.posid
,chg.dptid
,chg.priminsmne
,chg.priminscatid
,trn.payermne
,tcd.crcat
,chg.refprovid
,chg.modalid
,0
,0
,0
,0
,0
,trn.trnamt
,chg.chgallow
,0
,0
,0
,''
,0
,''
,'N'
,'N'
,'N'
,''
,Null
,chg.feetypeid
FROM tmp_dat_OtherTrans trn
LEFT JOIN infmtx_dat_Transactions chg on trn.chg_id = chg.tranid AND trn.chg_id = chg.chgid
AND trn.chg_id = chg.chgidagnst
LEFT JOIN infmtx_dic_TransCode tcd on trn.payermne = tcd.trancodemne
ORDER BY trn.tran_id;
[code]