0% found this document useful (0 votes)
21 views2 pages

JD

This SQL script performs the following actions: 1. Selects distinct records from the DET table and stores them in a temporary table #D. 2. Joins additional tables to retrieve account, address, and journal data and inserts it into the MJurnalUmumD table. 3. Drops the temporary table #D after the data insertion is complete.

Uploaded by

Sabadini FN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

JD

This SQL script performs the following actions: 1. Selects distinct records from the DET table and stores them in a temporary table #D. 2. Joins additional tables to retrieve account, address, and journal data and inserts it into the MJurnalUmumD table. 3. Drops the temporary table #D after the data insertion is complete.

Uploaded by

Sabadini FN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SELECT DISTINCT * INTO #D FROM DBCLA10.DBO.

DET A
INNER JOIN (
SELECT a.DET_NO as dn, a.DET_TGL as dt, MAX(DET_SYS) as D FROM
DBCLA10.DBO.DET a
where a.DET_MPRD = 330
GROUP BY a.DET_NO, a.DET_TGL
)b ON a.DET_NO = b.dn
and a.DET_TGL = b.dt
and a.DET_SYS = b.D
WHERE a.DET_MPRD = 330
--WHERE A.DET_MPRD = 330

--UPDATE DBCLA10.DBO.DET SET DET_NO = 'BM330.0036' WHERE DET_NO = 'BM330.036' AND


DET_TGL = 80896 AND DET_SYS = 168232

--select * from #D A
----where a.DET_NO = 'BK330.004'
--INNER JOIN MJurnalUmum b on a.DET_NO = b.Kode
----where a.DET_NO = 'BM330.036'
--WHERE ISNULL(b.KodeReff, '') = 'TSK10-06'
-- AND YEAR(b.Tanggal) = 2022
-- AND MONTH(b.Tanggal) = 6
-- and b.idjenistransaksi = 100
--delete from MJurnalUmumD where IDJurnalUmum = 2593
INSERT INTO [DBTSK].[dbo].[MJurnalUmumD]
([IDJurnalUmum]
,[IDDepartemen]
,[IDAkun]
,[IDMataUang]
,[Kurs]
,[Debet]
,[Kredit]
,[DebetA]
,[KreditA]
,[Keterangan]
,[IDGudang]
,[IDWilayah]
,[IDServerAsal]
,[IDPasangan]
,[IDAlamat]
,[IDRefParent]
,[HargaPokok]
,[IDRak]
,[Qty]
,[IDBarangD]
,[IDAsset]
,[ExpiredDate]
,[IDTipe]
,[IDMemoD]
,[IDAkunBankGiro]
,[IDCabang])
select b.ID [IDJurnalUmum]
,1 [IDDepartemen]
,c.ID [IDAkun]
,1 [IDMataUang]
,1 [Kurs]
,case when a.DET_DK = 'DB' THEN a.DET_NILAI ELSE 0 END [Debet]
,case when a.DET_DK = 'KR' THEN a.DET_NILAI ELSE 0 END [Kredit]
,case when a.DET_DK = 'DB' THEN a.DET_NILAI ELSE 0 END [DebetA]
,case when a.DET_DK = 'KR' THEN a.DET_NILAI ELSE 0 END [KreditA]
,a.DET_KET [Keterangan]
,1[IDGudang]
,1[IDWilayah]
,1[IDServerAsal]
,1 [IDPasangan]
,CASE
WHEN a.DET_KODE_C > 0 THEN d.NoID
WHEN a.DET_KODE_S > 0 THEN e.NoID ELSE 0
END [IDAlamat]
,0[IDRefParent]
,0[HargaPokok]
,1[IDRak]
,0[Qty]
,0[IDBarangD]
,0[IDAsset]
,'2022-07-02 13:33:26.090' [ExpiredDate]
,0[IDTipe]
,0[IDMemoD]
,0[IDAkunBankGiro]
,1[IDCabang] from #D A
INNER JOIN MJurnalUmum b on a.DET_NO + '-TSK10' = b.Kode
inner join MAkun c on a.Det_code = c.Kode
left join MAlamat d on cast(a.det_kode_c as varchar(50)) = d.Kode
and isnull(d.IsCustomer, 0) = 1
left join MAlamat e on cast(a.DET_KODE_S as varchar(50)) = e.Kode
and isnull(e.IsSupplier, 0) = 1
WHERE ISNULL(b.KodeReff, '') = 'TSK10-06'
AND YEAR(b.Tanggal) = 2022
AND MONTH(b.Tanggal) = 6

DROP TABLE #D

You might also like