-- cek data yang tidak ada
SELECT
  *
FROM
  tmp_prib_kontrak_provider
WHERE
  id_kontrak_provider NOT IN (SELECT id_kontrak_provider FROM kontrak_provider)

-- join (cek)
SELECT
  tmp.kode_provider,
  kp.kode_provider,
  tmp.[No Kontrak],
  kp.nomor_kontrak,
  tmp.Remarks,
  kp.catatan_kontrak,
  kp.catatan_provider,
  tmp.[Tgl Mulai],
  kp.tgl_mulai,
  tmp.[Tgl Selesai],
  kp.tgl_selesai
FROM
  tmp_prib_kontrak_provider AS tmp INNER JOIN
  kontrak_provider          AS kp  ON tmp.id_kontrak_provider=kp.id_kontrak_provider
WHERE
  tmp.[Tgl Selesai]<>kp.tgl_selesai
  --tmp.[Tgl Mulai]<>kp.tgl_mulai
  --tmp.[No Kontrak]<>kp.nomor_kontrak

-- beda
SELECT
  tmp.no,
  tmp.id_kontrak_provider,
  tmp.Provider,
  tmp.kode_provider,
  
  tmp.[Tgl Mulai],
  kp.tgl_mulai
FROM
  tmp_prib_kontrak_provider AS tmp INNER JOIN
  kontrak_provider          AS kp  ON tmp.id_kontrak_provider=kp.id_kontrak_provider
WHERE
  --tmp.[Tgl Selesai]<>kp.tgl_selesai
  tmp.[Tgl Mulai]<>kp.tgl_mulai
  --tmp.[No Kontrak]<>kp.nomor_kontrak
ORDER BY no

-- update
SELECT
  tmp.no,
  tmp.id_kontrak_provider,
  tmp.Provider,
  tmp.kode_provider,
  tmp.RI,
  tmp.RJ
FROM
  tmp_prib_kontrak_provider AS tmp INNER JOIN
  kontrak_provider          AS kp  ON tmp.id_kontrak_provider=kp.id_kontrak_provider
WHERE
  kp.ri IS NULL
  AND kp.rj IS NULL

--UPDATE
--  kp
--SET
--  ri = CASE
--          WHEN LOWER(tmp.RI)='x' THEN 1
--          ELSE NULL
--       END,
--  rj = CASE
--          WHEN LOWER(tmp.RJ)='x' THEN 1
--          ELSE NULL
--       END
--FROM
--  tmp_prib_kontrak_provider AS tmp INNER JOIN
--  kontrak_provider          AS kp  ON tmp.id_kontrak_provider=kp.id_kontrak_provider
--WHERE
--  kp.ri IS NULL
--  AND kp.rj IS NULL

