use zhengding SELECT * FROM TImpMember WHERE KHSJ00 = '15010655426' SELECT * FROM TImpMemberList WHERE KHSJ00 = '15010655426' SELECT * FROM timpmemberList_gam1501 SELECT * FROM timpmember_gam1501 SELECT * FROM TImpMemberList_jr001_ SELECT * FROM TImpMember_jr001 SELECT * FROM TImpMemberList_065 sp_rename 'TImpMemberList_jr001','TImpMemberList_jr001_' SELECT* FROM TImpMemberList_y506 SELECT* FROM TImpMember_y506 SELECT * FROM TImpMemberList_M700 SELECT KHBM00 FROM TImpMemberList_M700 GROUP BY KHBM00 HAVING SUM(1) > 1 SELECT VIPBM00 FROM TImpMember_M700 GROUP BY VIPBM00 HAVING SUM(1) > 1 SELECT * FROM TImpMemberList_C103 SELECT * FROM TImpMemberList_1201 SELECT* FROM TIMpMemberList_880 SELECT * FROM TIMPMEMBER_JD201 SELECT * FROM TImpMemberTransHist_GAM1501 SELECT * FROM sysobjects WHERE name LIKE 'TImpMemberList%' SELECT * FROM sysobjects WHERE name LIKE 'TImpMemberTrans%' SELECT *FROM TImpMemberList_Y506 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember_Y506 ) DELETE TImpMember_Y506 WHERE BMMC00 != '金源店' SELECT * FROM TImpMember_Y506 SELECT * FROM TImpMemberList_880 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember_880) SELECT VIPBM00 FROM TImpMember_880 GROUP BY VIPBM00 HAVING SUM(1) > 1 SELECT *FROM TImpMemberList_065 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember_065 ) SELECT * FROM TImpMemberList_M700 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember_M700) sp_rename 'TImpMemberList_C103_','TImpMemberList_C103' SELECT * FROM TImpMember_M700 SELECT count(1) FROM TImpMemberList_C103_ SELECT * FROM TImpMemberList_jr001 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember_jr001) SELECT * FROM TImpMember_C103 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMemberList_C103) AND BMMC00 like '%朝阳门%' SELECT * FROM TImpMember_C103 WHERE KHSJ00 ='15210069833' SELECT * FROM TImpMemberList_C103 WHERE KHSJ00 ='15210069833' ALTER TABLE TImpMemberList_Y506 ADD FIsLoad BIT NOT NULL DEFAULT 0 UPDATE TImpMemberList_Y506 SET FIsLoad = 1 WHERE KHSJ00 != '' AND KHSJ00 IN(SELECT KHSJ00 FROM TImpMember_Y506) SELECT count(1) FROM TImpMemberList_Y506 WITH(NOLOCK) WHERE KHSJ00 NOT IN(SELECT KHSJ00 FROM TImpMember_Y506 WITH(NOLOCK)) OR KHXM00 NOT IN(SELECT KHXM00 FROM TImpMember_Y506 WITH(NOLOCK)) OR KHDH00 NOT IN(SELECT KHDH00 FROM TImpMember_Y506 WITH(NOLOCK)) SELECT * FROM TImpMember_Y506 JD201 ok gam1501 ok jr001 ok 1201 ok 506 ok B109 ok 065 ok drop table TImpMemberList_jr001 SELECT count(1) FROM TImpMemberList_065 SELECT count(1) FROM TImpMember_065 DELETE TImpMember_B109 WHERE BMMC00 != '北苑' SELECT BMMC00,sum(1) FROM TImpMember_B109 GROUP BY BMMC00 SELECT COUNT(1) FROM TImpMemberlist_Y506 WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember_Y506) SELECT * FROM TImpMember_Y506 SELECT COUNT(1) FROM TImpMember_Y506 WHERE KHBM00 in(select KHBM00 from TImpMemberList_Y506) SELECT * FROM TImpMemberList_JR001 WHERE KHBM00 NOT IN(SELECT KHBM) SELECT KHBM00 FROM TImpMemberList_Y506 GROUP BY KHBM00 HAVING SUM(1 ) >1 SELECT * FROM TImpMemberList_Y506 WHERE KHSJ00 = '13439339637' SELECT * FROM TImpMemberList_B109 WHERE KHSJ00 = '13439339637' SELECT * FROM TImpMember WHERE KHSJ00 = '13439339637' SELECT * FROM TImpMember_B109 WHERE BMMC00 like '%金源%' SELECT * FROM TImpMemberList_Y506 WHERE KHXM00 = '徐婧' SELECT * FROM 90041 6 UPDATE TImpMember SET VIPKH00 = '90041 6' WHERE VIPBM00 = '' drop table TImpCompany DELETE A FROM TImpMember AS A,( SELECT VIPBM00,VIPKH00,MAX(FIndex) FIndex FROM TImpMember GROUP BY VIPBM00,VIPKH00 HAVING SUM(1) > 1) AS B WHERE A.VIPKH00 = B.VIPKH00 AND A.VIPBM00 = B.VIPBM00 AND A.FIndex != B.FIndex SELECT VIPKH00 FROM TImpMember GROUP BY VIPKH00 HAVING SUM(1) > 1 SELECT * FROM TImpMember use zhengding SELECT KHBM00 FROM TImpMemberList ORDER BY KHBM00 SELECT * FROM TImpMember WHERE VIPKH00 = '90041' sp_rename 'TImpMember', SELECT COUNT(1) FROM TImpMember WHERE BMMC00 ='金源店' SELECT * FROM TImpmember WHERE VIPBM00 = '110659' ALTER TABLE TImpMember ADD FIndex INT IDENTITY CREATE TABLE TImpCompany ( FUserNo VARCHAR(100), FCompId INT, FCompName NVARCHAR(100) ) DELETE TImpCompany INSERT TImpCompany(FUserNo,FCompId,FCompName) SELECT 'GAM1501',459,'广安门' UNION ALL SELECT 'jr001',538,'金融世家店' UNION ALL SELECT '065',374,'天通苑' UNION ALL SELECT 'Y506',242,'金源店' UNION ALL SELECT '506',231,'蓝靛厂店' UNION ALL SELECT 'M700',334,'马连道' UNION ALL SELECT 'C103',243,'朝阳门' UNION ALL SELECT '1201',335,'十里河' UNION ALL SELECT 'JD201',518,'金都杭城店' UNION ALL SELECT '880',314,'望京店' UNION ALL SELECT 'B109',437,'北苑' UNION ALL SELECT '063',354,'冠军城店' SELECT BMMC00 FROM TImpMember_B109 SELECT ' DROP TABLE TImpMember_' + FUserNo FROM TImpCompany DROP TABLE TImpMemberTransHist_GAM1501 DROP TABLE TImpMemberTransHist_C103 DROP TABLE TImpMemberTransHist_Y506 DROP TABLE TImpMember_Y506 DROP TABLE TImpMember_506 DROP TABLE TImpMember_M700 DROP TABLE TImpMember_C103 DROP TABLE TImpMember_1201 DROP TABLE TImpMember_JD201 DROP TABLE TImpMember_880 DROP TABLE TImpMember_B109 SELECT * FROM sysobjects where name like 'TImp%' DECLARE @SQL VARCHAR(1000) SELECT @SQL = '' SELECT @SQL = @SQL + name + ','FROM syscolumns WHERE id = object_id('TImpMemberList_GAM1501') PRINT @SQL SELECT BMMC00 FROM delete TIMpMember WHERE BMMC00 NOT IN(SELECT FCompName FROM TImpCompany) GROUP BY BMMC00 SELECT '459' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 INTO TImpmemberList FROM TImpMemberList_GAM1501 UNION ALL SELECT '538' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_jr001 UNION ALL SELECT '374' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_065 UNION ALL SELECT '242' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_Y506 UNION ALL SELECT '231' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_506 UNION ALL SELECT '334' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_M700 UNION ALL SELECT '243' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_C103 UNION ALL SELECT '335' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_1201 UNION ALL SELECT '518' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_JD201 UNION ALL SELECT '314' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_880 UNION ALL SELECT '437' AS FCompId, KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHRQLX,KHSR00,KHDH00,KHSJ00,KHTJBM,KHTJMC,KHRYBM,KHRYMC,KHDZ00,KHBZ00,VIPKH00,KZLIST,KHMDBM,LXMC00 FROM TImpMemberList_B109 SELECT *FROM TImpmemberList DELETE select BMMC00 FROM Timpmember WHERE BMMC00 IN(SELECT FCompName FROM TImpCompany) group by BMMC00 SELECT * FROM Timpmember SELECT COUNT(1) FROM TImpMember WITH(NOLOCK) WHERE FIsLoad = 0 update TImpMemberLIst set fisload =1 WHERE KHBM00 IN (SELECT KHBM00 FROM TImpMember) AND FIsLoad = 0 use zhengding WHERE KHBM00 NOT IN(SELECT KHBM00 FROM TImpMember WITH(NOLOCK)) AND KHBM00 > '118589' SELECT * FROM TImpMember WHERE vipbm00 = '123721' ORDER BY KHBM00 SELECT COUNT(1) FROM TImpMemberTransHist CREATE INDEX IDX_TImpMemberLIst_KHBM00 ON TImpMember(KHBM00) CREATE INDEX IDX_TImpMember_KHBM00 ON TImpMember(KHBM00) SELECT KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHSR00,KHDH00,KHSJ00,VIPBM00,VIPKH00,VIPKLX0,VIPLX00,VIPZTBJ,VIPBZ00,VIPBZ03,VIPDJMC,ZHLIST,JEZH,CSZH,ZSZH,JEQK,CSQK,SDQK,LXMC00,BMMC00,VIPMMBJ,ZHLX01,ZHQKJE,VIPMM00,ZHJE00,ZHXMBJ,XMBJ,CPBJ,KKBJ,CKBJ,ZCBJ,VIPJF00,VIPJSMD,LXCKBJ,SYLIST,VIPDXBJ,KZLIST,KHMDBM,KHMDMC,KHMDBH,BMBM00,BMBH00,VIPWXBJ,KHTP00,VIPGXSJ,LXTYBJ,VIPYXSJ,LXDQBJ into TImpMember FROM TImpMember_GAM1501 UNION ALL SELECT KHBM00,KHDJRQ,KHXM00,KHXB00,KHZW00,KHJRFS,KHSFZ0,KHSR00,KHDH00,KHSJ00,VIPBM00,VIPKH00,VIPKLX0,VIPLX00,VIPZTBJ,VIPBZ00,VIPBZ03,VIPDJMC,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