1-) MSSQL RMOS - master id leri detail id ye yazma
select a.*,b.say from (select rez_id,rez_masterId,rez_voucher,rez_acenteVoucher,rez_hotel,rez_firma_ad,rez_acente from rez ) a
left join
(select min( rez_id) say,rez_masterId,rez_voucher,rez_acenteVoucher,rez_hotel,rez_firma_ad,rez_acente from rez
group by rez_masterId,rez_voucher,rez_acenteVoucher,rez_hotel,rez_firma_ad,rez_acente) b
on a.rez_voucher=b.rez_voucher
and a.rez_acenteVoucher= b.rez_acenteVoucher
and a.rez_firma_ad= b.rez_firma_ad
and a.rez_acente=b.rez_acente
order by 1
update a set a.rez_masterId=b.say from (select rez_id,rez_masterId,rez_voucher,rez_acenteVoucher,rez_hotel,rez_firma_ad,rez_acente from rez ) a
left join
(select min( rez_id) say,rez_masterId,rez_voucher,rez_acenteVoucher,rez_hotel,rez_firma_ad,rez_acente from rez
group by rez_masterId,rez_voucher,rez_acenteVoucher,rez_hotel,rez_firma_ad,rez_acente) b
on a.rez_voucher=b.rez_voucher
and a.rez_acenteVoucher= b.rez_acenteVoucher
and a.rez_firma_ad= b.rez_firma_ad
and a.rez_acente=b.rez_acente