|
|
|
|
SELECT * FROM gam10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM gdm14
|
|
|
|
|
WHERE gdn00c = '004'
|
|
|
|
|
AND FItemId = '4671086498297546148'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM gdm15 WHERE FId = '7705184060480957101'
|
|
|
|
|
|
|
|
|
|
SELECT A.FId,A.FParentId,A.FCardTypeId,A.FPayTypeId,ISNULL(dbo.FNBKdate(A.gdo04d),''1753-01-01''),ISNULL(dbo.FNBKdate(A.gdo04d),''9999-12-31'')
|
|
|
|
|
FROM
|
|
|
|
|
|
|
|
|
|
ALTER TABLE gdm14 ADD FId varchar(20) NOT NULL DEFAULT abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT))
|
|
|
|
|
ALTER TABLE gdm14 ADD FItemId varchar(20) NOT NULL default ''
|
|
|
|
|
ALTER TABLE gdm15 ADD FId varchar(20) NOT NULL DEFAULT abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT))
|
|
|
|
|
ALTER TABLE gdm16 ADD FId varchar(20) NOT NULL DEFAULT abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT))
|
|
|
|
|
|
|
|
|
|
ALTER TABLE gdm15 ADD FCardTypeId varchar(20) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE gdm15 ADD FPayTypeId varchar(20) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE gdm15 ADD FParentId varchar(20) NOT NULL DEFAULT '0'
|
|
|
|
|
|
|
|
|
|
ALTER TABLE gdm16 ADD FParentId varchar(20) NOT NULL DEFAULT '0'
|
|
|
|
|
ALTER TABLE gdm16 ADD FMasterId varchar(20) NOT NULL DEFAULT '0'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM gdm14 WHERE FId = '4692801313661198966'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM gam10 WHERE gak00c = '009' AND gak01c = '1'
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FParentId = B.FId
|
|
|
|
|
FROM gdm15 AS A,gdm14 AS B
|
|
|
|
|
WHERE A.gdm15fk = B.gdm14id
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FParentId = B.FId
|
|
|
|
|
FROM gdm16 AS A,gdm15 AS B
|
|
|
|
|
WHERE A.gdm16fk = B.gdm15id
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMasterId = C.FId
|
|
|
|
|
FROM gdm16 AS A,gdm15 AS B,gdm14 AS C
|
|
|
|
|
WHERE A.gdm16fk = B.gdm15id
|
|
|
|
|
AND B.gdm15fk = C.gdm14id
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ۿۿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardTypeId = C.FId
|
|
|
|
|
FROM gdm15 AS A,gdm14 AS B,gam10 AS C
|
|
|
|
|
WHERE A.gdm15fk = B.gdm14id
|
|
|
|
|
AND B.gdn00c = c.gak00c
|
|
|
|
|
AND A.gdo02c = C.gak01c
|
|
|
|
|
|
|
|
|
|
SELECT * FROM gdm15
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ۿ<EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FId
|
|
|
|
|
FROM gdm14 AS A,gdm01 AS B
|
|
|
|
|
WHERE A.gdn05c = B.gda01c
|
|
|
|
|
AND A.gdn00c = B.gda00c
|
|
|
|
|
AND A.gdn04i = 1
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FId
|
|
|
|
|
FROM gdm14 AS A,gdm01 AS B
|
|
|
|
|
WHERE A.gdn05c = B.gda01c
|
|
|
|
|
AND A.gdn00c = B.gda00c
|
|
|
|
|
AND A.gdn04i = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM gdm16
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
----------------------------------------------
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ID,<EFBFBD>Ƴ<EFBFBD>ID,<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
delete gam10 where FFromChild = 1
|
|
|
|
|
|
|
|
|
|
UPDATE gam10 SET FNo = gak01c
|
|
|
|
|
|
|
|
|
|
select * into #gam10 from gam10 where 1=2
|
|
|
|
|
|
|
|
|
|
declare @CompNo VARCHAR(200)
|
|
|
|
|
declare #Companys cursor for
|
|
|
|
|
select distinct gae01c from gam05 where gae01c != '001'
|
|
|
|
|
|
|
|
|
|
open #Companys
|
|
|
|
|
fetch #Companys into @CompNo
|
|
|
|
|
while @@fetch_status=0
|
|
|
|
|
begin
|
|
|
|
|
delete #gam10
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--declare @CompNo VARCHAR(200)
|
|
|
|
|
-- select @compNo = '008'
|
|
|
|
|
insert #gam10
|
|
|
|
|
select b.* from
|
|
|
|
|
(select gak01c,gak02c,FId from gam10 where gak00c = '001') as a,
|
|
|
|
|
(select * from gam10 where gak00c = @CompNo) as b
|
|
|
|
|
where (a.gak01c = b.gak01c )
|
|
|
|
|
and a.gak02c != b.gak02c
|
|
|
|
|
and b.gak01c + '.' + @CompNo not in (select gak01c from gam10 where gak00c = '001')
|
|
|
|
|
|
|
|
|
|
update #gam10 set FNo = gak01c + '.' + @CompNo
|
|
|
|
|
|
|
|
|
|
update a
|
|
|
|
|
set a.FNo = b.FNo
|
|
|
|
|
from gam10 as a,#gam10 as b
|
|
|
|
|
where a.gak00c = @CompNo
|
|
|
|
|
and a.gak01c = b.gak01c
|
|
|
|
|
|
|
|
|
|
update #gam10 set gak01c = FNo ,gak00c = '001',FFromChild = 1
|
|
|
|
|
|
|
|
|
|
insert gam10
|
|
|
|
|
select * from #gam10
|
|
|
|
|
|
|
|
|
|
delete #gam10
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ȡ001<EFBFBD><EFBFBD>˾û<EFBFBD>е<EFBFBD>
|
|
|
|
|
insert #gam10
|
|
|
|
|
select *
|
|
|
|
|
from gam10
|
|
|
|
|
where gak00c = @CompNo
|
|
|
|
|
and gak01c not in (select gak01c from gam10 where gak00c = '001')
|
|
|
|
|
|
|
|
|
|
update #gam10 set gak00c = '001',FFromChild = 1
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>001<EFBFBD><EFBFBD>˾
|
|
|
|
|
INSERT gam10
|
|
|
|
|
select * from #gam10
|
|
|
|
|
|
|
|
|
|
fetch #Companys into @CompNo
|
|
|
|
|
end
|
|
|
|
|
close #Companys
|
|
|
|
|
deallocate #Companys
|
|
|
|
|
drop table #gam10
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD>Ÿ<EFBFBD><EFBFBD><EFBFBD>ID
|
|
|
|
|
update a
|
|
|
|
|
set a.FId = b.FId
|
|
|
|
|
FROM gam10 AS A, (select FNo,FId from gam10 where gak00c = '001') AS B
|
|
|
|
|
WHERE a.gak00c NOT IN('','001')
|
|
|
|
|
AND a.FNo = B.FNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|