USE qd_GONG9CM8YFnqg9FQ9cYM GO SELECT * FROM TMember WHERE FId IN ( SELECT FMemId FROM TMemberTransHIst WHERE FMemId IN(SELECT FId FROM TMember WHERE FCompID = 3472615061795635200) ) SELECT * FROM TCompany SELECT * FROM gcm01 WHERE gca00c = gca13d SELECT gca01c,sum(1) FROM gcm01 WHERE gca00c = gca13d GROUP BY gca01c ORDER BY sum(1) desc SELECT * FROM gcm01 WHERE gca01c = '800690' SELECT * FROM gbm01 WHERE gba01c = '800690' CREATE TABLE #Card ( CardNo VARCHAR(20) ) insert #Card VALUES('802286') insert #Card VALUES('802002') insert #Card VALUES('802037') insert #Card VALUES('802297') insert #Card VALUES('803680') insert #Card VALUES('800690') SELECT * INTO #NewCard FROM #Card UPDATE #NewCard SET CardNo = CardNo + '.' SELECT DELETE gcm01 WHERE gca01c IN(SELECT CardNo FROM #Card) DELETE gcm03 WHERE gcc01c IN(SELECT CardNo FROM #Card) DELETE gcm02 WHERE gcb01c IN(SELECT CardNo FROM #Card) DELETE gcm05 WHERE gce01c IN(SELECT CardNo FROM #Card) DELETE gcm20 WHERE gct02c IN(SELECT CardNo FROM #Card) DELETE gcm04 WHERE gcd01c IN(SELECT CardNo FROM #Card) DELETE gbm01 WHERE gba01c IN(SELECT CardNo FROM #Card) INSERT gcm01 SELECT * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm01 WHERE gca01c IN(SELECT gca01c FROM #card) INSERT gcm03 SELECT * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm03 WHERE gcc01c IN(SELECT gca01c FROM #card) INSERT gcm02 SELECT * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm02 WHERE gcb01c IN(SELECT gca01c FROM #card) INSERT gcm05 SELECT * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm05 WHERE gce01c IN(SELECT gca01c FROM #card) delete gcm20 where gct02c in (SELECT gca01c FROM #card) INSERT gcm20(gct00c,gct02c,gct03c,gct04d,gct05c,gct06c,gct07c,gct08c,gct09f,gct10f,gct11f,gct12f,gct13c,gct14c,gct15c,gct16c,gct17c,gct18c) SELECT gct00c,gct02c,gct03c,gct04d,gct05c,gct06c,gct07c,gct08c,gct09f,gct10f,gct11f,gct12f,gct13c,gct14c,gct15c,gct16c,gct17c,gct18c FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm20 WHERE gct02c IN(SELECT gca01c FROM #card) INSERT gcm04 SELECT * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm04 WHERE gcd01c IN(SELECT gca01c FROM #card) INSERT gbm01 SELECT * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gbm01 as b WHERE b.gba01c IN(SELECT gca01c FROM #card) and not exists (select a.gba01c from gbm01 as a where a.gba00c = b.gba00c and a.gba01c = b.gba01c) select * FROM db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm01 where gca01c in (SELECT gca01c FROM #card) SELECT * FROM gbm01 WHERE gba01c IN(SELECT gca01c FROM #card) select * from gcm04 where gcd01c in (SELECT gca01c FROM #card) delete gbm01 SELECT * FROM gcm01 WHERE gca01c IN ( SELECT CardNo FROM #Card ) AND gca00c = gca13d 800690. 803680. 802002. 802037. 802286. 802297. SELECT * FROM gcm20 WHERE gct02c in ( SELECT CardNo FROM #Card ) AND gct04d > '20151009' SELECT * FROM gcm06 select * from db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm01 WHERE gca01c like '%.' gca01c in ( SELECT CardNo FROM #Card ) select 'EXEC upg_rename_cardid_ex ''' + CardNo +''',''' + CardNo + '.'',' + '''Admin'',''20151016'',''170000''' FROM #Card --µ¼004µÄ select * into #card from db2.qd_JIALIXIUCHANG7Yc5O0V.dbo.gcm01 WHERE gca00c = gca13d and gca00c = '004' and gca01c not in(select gca01c from gcm01 where gca00c = gca13d ) and gca01c not in(select gca01c from #card) select gca01c,name,phone from #card alter table #card add phone varchar(30) alter table #card add name varchar(30) update a set a.phone = b.gba08c, a.name = b.gba03c from #card as a,gbm01 as b where gca04c = gba01c select * from gcm01 where gca01c = '801635' select * from gbm01 where gba01c = '900601'