sql >> Base de Datos >  >> RDS >> Sqlserver

Insertar datos no duplicados de la tabla principal a la tabla secundaria en el servidor SQL 2008

Reemplazar esta parte

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) )