use yantai_mingmenrunxiu

SELECT * FROM TMember WHERE FMemNO = '101912'


SELECT * FROM TMemberTransHist WHERE FMemId = 6622452803399860573

SELECT * FROM TMemberCard WHERE FMemId = 6622452803399860573

use chongqing_qipin

SELECT * FROM TUser

SELECT * FROM TMemberEarnestMoneyLog 
UPDATE TMemberEarnestMoneyLog SET FBillType = 'KK' WHERE FBillType = 'XF' AND FBizType = 'CardRchg'

SELECT * FROM bbm..TMemberCard WHERE FCardId = 5061830792581480907
SELECT * FROM bbm..TMemberCardAccount WHERE FMemId = 8854150773063620085

SELECT * FROM bbm..TMemberCardAcctHist WHERE FMemId = 8854150773063620085

EXEC sp_helptext 'PMergeMember'

SELECT * FROM TConsumeBill WHERE FMemNO LIKE '285812%'

UPDATE T

PRecalcCardAccHistBalance 5226237975433534617

SELECT * FROM TMemberMerge WHERE FSourcememID = 6622452803399860573
SELECT * FROM TMemberMergeDetail WHERE FSourceMemId = 6622452803399860573

SELECT * FROM TMemberMergeDetail WHERE FTargetMemId = 7580188933148551519
SELECT * FROM TMemberMerge WHERE FTargetMemId = 7580188933148551519

SELECT * FROM TMemberMergeDetail WHERE FTargetMemId = 5798623987403759879

SELECT * FROM TMemberCardAcctHist WHERE FCardId = 5061830792581480907
AND FId NOT  IN(SELECT FDetailId FROM TMemberMergeDetail WHERE FTargetMemId = 4838575551147912738)


select * from tmEMBER WHERE FMemID=5516285282714993402

   DELETE TMemberMerge WHERE FTargetMemId = 5798623987403759879
   DELETE TMemberMergeDetail WHERE FTargetMemId = 5798623987403759879



SELECT * FROM TCompany WHERE Fid = 5088507307030413364

SELECT * FROM TMemberTransHist WHERE FMemId = 5516285282714993402

UPDATE A
   SET A.FCardId = B.FSourceCardId,
       A.FMemId = B.FSourceMemId
  FROM TMemberTransHist AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'TransHist'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FCardId
   AND B.FTargetMemId = 7580188933148551519

UPDATE A
   SET A.FCardId = B.FSourceCardId,
       A.FMemId = B.FSourceMemId
  FROM TMemberOldTransHist AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'OldTransHist'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FCardId
   AND B.FTargetMemId = 7580188933148551519
   
   UPDATE A
   SET A.FCardId = B.FSourceCardId,
       A.FMemId = B.FSourceMemId
  FROM TMemberCardOldAcctHist AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'CardOldAcctHist'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FCardId
   AND B.FTargetMemId = 7580188933148551519
   
UPDATE A
   SET A.FCardId = B.FSourceCardId,
       A.FMemId = B.FSourceMemId
  FROM TMemberCardAcctHist AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'CardAcctHist'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FCardId
   AND B.FTargetMemId = 7580188933148551519
   
UPDATE A
   SET A.FCardId = B.FSourceCardId,
       A.FMemId = B.FSourceMemId
  FROM TMemberPointHist AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'PointHist'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FCardId
   AND B.FTargetMemId = 7580188933148551519
   
UPDATE A
   SET A.FMemId = B.FSourceMemId
  FROM TMemberCourse AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'Course'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FId
   AND B.FTargetMemId = 7580188933148551519
   
    
    UPDATE A
   SET A.FMemId = B.FSourceMemId
  FROM TMemberCourseLog AS A,TMemberMergeDetail AS B
 WHERE A.FId = B.FDetailId
   AND B.FDetailType = 'CourseHist'
   AND B.FSourceMemId != A.FMemId
   AND B.FSourceCardID != A.FCardId
   AND B.FTargetMemId = 7580188933148551519
   
     
   
   SELECT * FROM TMemberMergeDetail WHERE FTargetMemId = 7580188933148551519
   
   
   
     UPDATE A
     SET A.FMemId = B.FMemId,
         A.FCardId = B.FCardId
   FROM TMemberTransHist AS A,MMRX..TMemberTransHist AS B
  WHERE A.FId = B.FId
  AND A.FId IN(SELECT FDetailId FROM TMemberMergeDetail WHERE  FDetailType = 'TransHist')
   
   DELETE TMemberMerge WHERE FTargetMemId = 
   
   SELECT * FROM TUser
   
   SELECT * FROM TMember WHERE Fmemid = 8854150773063620085
   
   UPDATE A
      SET A.FMemNo = B.FMemNo
    FROM TConsumeBill AS A,TMember AS B
   WHERE A.FMemId = B.FMemId
     AND A.Fmemid = 6622452803399860573

   UPDATE A
      SET A.FCardNo = B.FCardNo
    FROM TConsumeBill AS A,TMemberCard AS B
   WHERE A.FMemId = B.FMemId
     AND A.Fmemid = 6622452803399860573
     
     
     SELECT * FROM BBM..TConsumeBill WHERE FMemID = 8854150773063620085
     
     INSERT TCOnsumeBill
     SELECT * FROM BBM..TConsumeBill WHERE FBillId = 5622590075862762365
     
          INSERT TCOnsumeItem
     SELECT * FROM BBM..TCOnsumeItem WHERE FBillId = 5622590075862762365
     
          INSERT TCOnsumeItemPayment
     SELECT * FROM BBM..TCOnsumeItemPayment WHERE FBillId = 5622590075862762365
     
          INSERT TCOnsumeItemEmployee
     SELECT * FROM BBM..TCOnsumeItemEmployee WHERE FBillId = 5622590075862762365
     

          INSERT TCOnsumeGoods
     SELECT * FROM BBM..TCOnsumeGoods WHERE FBillId = 5622590075862762365
 
           INSERT TCOnsumeGoodsEmployee
     SELECT * FROM BBM..TCOnsumeGoodsEmployee WHERE FBillId = 5622590075862762365
   
   
           INSERT TCOnsumeGoodsPayment
     SELECT * FROM BBM..TCOnsumeGoodsPayment WHERE FBillId = 5622590075862762365
      
      SELECT * FROM TConsumeBill WHERE FBillId = 5622590075862762365
      
      UPDATE TConsumeBill SET FState = 0 WHERE FBillId = 5622590075862762365
      
      EXEC PAuditConsumeBill 5622590075862762365,1,8350196816206767491
      
      SELECT * FROM TMemberCardAccount WHERE FMemId = 8854150773063620085
      
SELECT * FROM TConsumeBill WHERE FBillId IN(SELECT FTransId FROM TMemberTransHist WHERE FMemId = 5798623987403759879)

SELECT * FROM TMemberTransHist WHERE FMemId = 5798623987403759879

    UPDATE A
       SET A.FMemId = B.FMemId,
           A.FCardId = B.FCardId
     FROM TConsumeBill AS A,TMemberTransHist AS B
     WHERE B.FTransId = A.FBillId
     AND B.FMemId = 6622452803399860573
     
   
       UPDATE A
       SET A.FCardId = B.FCardId
     FROM TConsumeItemPayment AS A,TMemberTransHist AS B
     WHERE B.FTransId = A.FBillId
     AND B.FMemId = 6622452803399860573

  
UPDATE TMember SET FState = 1 WHERE FMemId = 6622452803399860573
UPDATE TMemberCard SET FState = 1 WHERE FMemId = 6622452803399860573

SELECT * FROM TUser

SELECT * FROM TMember WHERE FMemID = 5516285282714993402

