You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

149 lines
4.1 KiB

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
--ÕÛ¿Û¿¨Àà±ð
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
--ÕÛ¿ÛÏîÄ¿
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
----------------------------------------------
--´¦ÀíÏîÄ¿±àºÅ,ID,ÁƳÌID,Öظ´µÄÏîÄ¿
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
--¸üÐÂÖظ´µÄ
--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
--»ñÈ¡001¹«Ë¾Ã»ÓеÄ
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
--²åÈë001¹«Ë¾
INSERT gam10
select * from #gam10
fetch #Companys into @CompNo
end
close #Companys
deallocate #Companys
drop table #gam10
--¸üиù¾Ý±àºÅ¸üÐÂ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