Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Insertion de données non dupliquées de la table parent à la table enfant dans SQL Server 2008

Remplacez cette pièce

not exists
( SELECT 1
 FROM OSUSR_1SV_QAD_PO_DATA B
 WHERE
  A.TENANT_ID = B.TENANT_ID
   --and A.CUSTOMER_PART_NUMBER = A.CUSTOMER_PART_NUMBER --you are Comparing same value here
   and A.CUSTOMER_PART_NUMBER = B.CUSTOMER_PART_NUMBER  
   and A.SHIPPING_ID = B.SHIPPING_ID
   and  CAST(A.EFFECTIVE_DATE AS DATE) = CAST(B.EFFECTIVE_DATE AS DATE) )