SELECT
	sumber.*,
	krm.No_Ref,
	ntm.*
FROM
	temp_prib_20151215_1 AS sumber LEFT JOIN
	dbo.Klaim_Ref_Master AS krm ON sumber.No_Klaim = krm.No_Klaim INNER JOIN
	dbo.Note_Terbit_Master AS ntm ON krm.No_Ref = ntm.No_Ref
WHERE
  sumber.No_Klaim IS NOT NULL
  --AND ntm.Status = 'I'
ORDER BY
  sumber.no

--SELECT
--	*
--FROM
--	dbo.Klaim_Ref_Master
--WHERE
--  YEAR(Create_Date) = 2015
--  AND Status = 'I'


SELECT
	sumber.*,
	krm.No_Ref,
	ntm.*
--UPDATE
--  sumber
--SET
--  no_ref = ntm.No_Ref
FROM
	temp_prib_20151215_1 AS sumber LEFT JOIN
	dbo.Klaim_Ref_Master AS krm ON sumber.No_Klaim = krm.No_Klaim INNER JOIN
	dbo.Note_Terbit_Master AS ntm ON krm.No_Ref = ntm.No_Ref
WHERE
  sumber.No_Klaim IS NOT NULL
  --AND ntm.Status = 'I'
ORDER BY
  sumber.no

SELECT
	*
FROM
	temp_prib_20151215_1 INNER JOIN
	dbo.Klaim_Peserta AS kp ON dbo.temp_prib_20151215_1.No_Klaim = kp.No_Klaim

SELECT
	*
FROM
	dbo.Note_Provider_Master

SELECT
	*
FROM
	--dbo.Note_Terbit_Provider_Detail
	dbo.Note_Terbit_Provider_Header

SELECT * FROM Note_Terbit_Provider_Detail
WHERE No_Ref='2015.049435' --No_Ref_Provider=:No_Ref_Provider

SELECT
	sumber.*,
	ntpd.*
UPDATE
  sumber
SET
  no_ref_provider = ntpd.No_Ref_Provider
FROM
	temp_prib_20151215_1 AS sumber LEFT JOIN
	dbo.Note_Terbit_Provider_Detail AS ntpd ON sumber.no_ref = ntpd.No_Ref
WHERE
  sumber.No_Klaim IS NOT NULL
  --AND ntm.Status = 'I'
ORDER BY
  sumber.NO
  

SELECT
	*
FROM
	temp_prib_20151215_1
ORDER BY
  no