0
SELECT
ob.SubscriberKey,
ob.EmailAddress,
ob.fname, 
ob.Country,
ob.Language, 
ob.fin_no,
dw.username,
dw.password,
fp.FirstOrderDate

 

FROM FP_Onboarding_Root AS ob
LEFT JOIN Active_FP_JP AS fp ON fp.SID = ob.SubscriberKey
LEFT JOIN ent.DISTWELCOME_JP AS dw ON dw.EmailAddress = ob.EmailAddress

 

WHERE (fp.FirstOrderDate is null OR fp.FirstOrderDate = '')
AND ob.EmailAddress IS NOT NULL

This works fine in query studio and pull all the relevant data, but as soon as I put it in an automation I get the error:

Violation of PRIMARY KEY constraint. Cannot insert duplicate key.

I am only using the SubscriberKey as primary key in the DE

3
  • 2
    Does this answer your question? SQL query Error Violation of PRIMARY KEY
    – Niko
    Jul 6 at 13:13
  • also, it works fine in the Query Studio only because of the fact that Query Studio creates temporary Data Extension without specific structure and primary keys, thus you can have there all possible values, including duplicated ones.
    – Niko
    Jul 6 at 13:13
  • ** so I figured this out, ent.DISTWELCOME_JP did not have a subscriberkey and was being sourced by email, I had the Automation set to Update!!!!! If I set the Automation DE to override the the automation runs fine and the DE is populated.
    – Factor33
    Jul 7 at 16:52