SELECT
  temp.[no],
  temp.[nama],
  temp.[tgl_lahir],
  temp.[pl],
  pst.No_Peserta,
  pst.Nama,
  pst.Status,
  pst.No_Proposal,
  pa.No_Polis,
  prs.Nama_Perusahaan
FROM
  [db_no_replicate_space].[dbo].[temp_prib_cek_multipolis] AS temp INNER JOIN
  dbo.Peserta AS pst ON temp.tgl_lahir = pst.Tgl_Lahir
                        AND temp.pl = pst.Kelamin
                        AND LEFT(temp.nama,7) = LEFT(pst.Nama,7) INNER JOIN
  dbo.Polis_Asuransi AS pa ON pst.No_Proposal = pa.No_Proposal INNER JOIN
  dbo.Perusahaan AS prs ON pa.No_Prs = prs.No_Prs
ORDER BY
  temp.[no],
  prs.Nama_Perusahaan
  
SELECT *
FROM
	[db_no_replicate_space].[dbo].[temp_prib_cek_multipolis]

--UPDATE [db_no_replicate_space].[dbo].[temp_prib_cek_multipolis] SET pl='W' WHERE pl='P'
--UPDATE [db_no_replicate_space].[dbo].[temp_prib_cek_multipolis] SET pl='P' WHERE pl='L'
--SELECT
--	*,
--	REPLACE(nama,', AAAIJ','') AS a
--FROM
--	[db_no_replicate_space].[dbo].[temp_prib_cek_multipolis]
--WHERE
--  nama LIKE '%, AAAIJ%'
----UPDATE
----	[db_no_replicate_space].[dbo].[temp_prib_cek_multipolis]
----SET
----  nama = REPLACE(nama,', AAK','')
----WHERE
----  nama LIKE '%, AAK%'

--SELECT
--	*,
--	REPLACE(nama,', AAAK','') AS a
--FROM
--	[db_no_replicate_space].[dbo].[temp_prib_cek_multipolis]
--WHERE
--  nama LIKE '%, AAAK%'
----UPDATE
----	[db_no_replicate_space].[dbo].[temp_prib_cek_multipolis]
----SET
----  nama = REPLACE(nama,', AAAK','')
----WHERE
----  nama LIKE '%, AAAK%'