Copy CTGS + CDTK

Copy CTGS

select * into #ctgs from zcctgs where ma_Dvcs = '9999' and nam = '2020'
update #ctgs set ma_dvcs = '0001', tien = 0
delete zcctgs where ma_dvcs = '0001' and nam = '2020'
insert into zcctgs select * from #ctgs

'0001' là mã đơn vị cần copy

Copy cdtk theo mã đơn vị

select * into #f from cdtk where nam = 2014 and ma_dvcs='CNDT02' and tk not in (select tk from cdtk where nam = 2022 and ma_dvcs='CNDT02') 
update #f set nam = 2022 insert into cdtk select * from #f

Copy cdtk

select * into #e from cdtk where nam = 2014 and tk not in (select tk from cdtk where nam = 2020)
update #e set nam = 2020 
insert into cdtk select * from #e

Last updated

Was this helpful?