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.
239 lines
5.4 KiB
239 lines
5.4 KiB
|
|
|
|
DROP TABLE TSameMember
|
|
|
|
SEL
|
|
|
|
SELECT FMobilePhone,FName,SUM(1) AS FCount,MIN(FIndex) AS FCreateDate INTO TSameMember
|
|
FROM TMember
|
|
WHERE FMobilePhone != ''
|
|
AND dbo.FNIsMobile(FMobilePhone) = 1
|
|
GROUP BY FMobilePhone,FName
|
|
HAVING (COUNT(1) > 1)
|
|
ORDER BY FMobilePhone DESC
|
|
|
|
DROP TABLE TSameMemberMaster
|
|
SELECT * INTO TSameMemberMaster FROM TMember AS A
|
|
WHERE EXISTS(SELECT 1 FROM TSameMember AS B WHERE B.FMobilePhone = A.FMobilePhone AND A.FName = B.FName
|
|
AND B.FCreateDate = A.FIndex)
|
|
|
|
SELECT * FROM TMember AS A
|
|
WHERE EXISTS(SELECT 1 FROM TSameMember AS B WHERE B.FMobilePhone = A.FMobilePhone AND A.FName = B.FName )
|
|
|
|
SELECT 4082-2497
|
|
|
|
SELECT COUNT(1 ) FROM TSameMember
|
|
|
|
ORDER BY SUM(1) DESC
|
|
|
|
SELECT IDENTITY(INT,1,1) AS FIndex,FMemId INTO #Member FROM TMember
|
|
ORDER BY FMobilePhone,FName,FCreateDate
|
|
|
|
UPDATE A
|
|
SET A.FIndex = B.FIndex
|
|
FROM TMember AS A,#Member AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
SELECT * FROM TMember
|
|
|
|
SELECT FMobilePhone,FName,SUM(1) AS FCount,MIN(FCreateDate) AS FCreateDate INTO TSameMember
|
|
FROM TMember
|
|
WHERE FMobilePhone != ''
|
|
AND dbo.FNIsMobile(FMobilePhone) = 1
|
|
GROUP BY FMobilePhone,FName
|
|
HAVING (COUNT(1) > 1)
|
|
ORDER BY FMobilePhone DESC
|
|
|
|
ALTER TABLE TMember ADD FNewMemId BIGINT,FNewMemNo VARCHAR(30)
|
|
|
|
UPDATE A
|
|
SET A.FNewMemId = B.FMemId,
|
|
A.FNewMemNo = B.FMemNo
|
|
FROM TMember AS A,TSameMemberMaster AS B
|
|
WHERE A.FMobilePhone = B.FMobilePhone
|
|
AND A.FName = B.FName
|
|
AND A.FIndex != B.FIndex
|
|
|
|
SELECT * FROM TMember WHERE FNewMemId IS NOT NULL
|
|
|
|
SELECT * FROM
|
|
|
|
|
|
--正式更新
|
|
|
|
SELECT * FROM TMember WHERE FNewMemId != 0
|
|
|
|
UPDATE TMember SET FNewMemId = 0 WHERE FNewMemId IS NULL
|
|
UPDATE TMember SET FNewMemNo = '' WHERE FNewMemNo IS NULL
|
|
|
|
UPDATE A
|
|
SET A.FMemo = A.FMemo + '[已经合并到' + A.FNewMemNo + ']'
|
|
FROM TMember AS A
|
|
WHERE FNewMemId IS NOT NULL
|
|
|
|
UPDATE A
|
|
SET A.FMemNo = A.FMemNo + '[已经合并到' + A.FNewMemNo + ']'
|
|
FROM TMember AS A
|
|
WHERE FNewMemId IS NOT NULL
|
|
|
|
UPDATE TMember SET FState = 3,FMemNo = FMemNo + '[已合并]'
|
|
WHERE FNewMemId != 0
|
|
|
|
--卡
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCard AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
|
|
|
|
--账户
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCardAccount AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--账户历史
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCardAcctHist AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCardOldAcctHist AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--疗程
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCourse AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--疗程历史
|
|
--疗程
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCourseHist AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--交易历史
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberTransHist AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberOldTransHist AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
|
|
--交易历史支付明细
|
|
--交易历史
|
|
--疗程
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberTransHistPayment AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
|
|
--积分历史
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberPointHist AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
|
|
--欠款
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberArrear AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
|
|
--欠款
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberArrearEmployee AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
|
|
--欠款
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberSaleBill AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--提醒
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId,
|
|
A.FMemNo = B.FNewMemNo
|
|
FROM TMemberRemind AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--消费
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId,
|
|
A.FMemNo = B.FNewMemNo
|
|
FROM TConsumeBill AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
--开卡
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId,
|
|
A.FMemNo = B.FNewMemNo
|
|
FROM TMemberSaleBill AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
|
|
SELECT * FROM sysobjects WHERE name like '%Member%' and type = 'U'
|
|
|
|
SELECT * FROM TMemberCoursePack
|
|
|
|
--照片
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberPhoto AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
AND B.FNewMemId NOT IN(SELECT FMemId FROM TMemberPhoto)
|
|
AND B.FMemId NOT IN(4622709038010346916,8272471197083282758,6864468426306491951)
|
|
|
|
DROP TABLE #Photo
|
|
SELECT B.FMemId,B.FNewMemId,A.Ftype,A.FImagePath,A.FChangeId,IDENTITY(INT,1,1)FIndex INTO #Photo FROM TMemberPhoto AS A,TMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FNewMemId != 0
|
|
AND B.FNewMemId NOT IN(SELECT FMemId FROM TMemberPhoto)
|
|
ORDER BY FNewMemId
|
|
|
|
SELECT FNewMemId ,SUM(1),MIN(FMemId) FROM #Photo
|
|
GROUP BY FNewMemId
|
|
HAVING (SUM(1) ) > 1
|
|
|
|
DELETE #Photo WHERE FMemId IN(4622709038010346916,8272471197083282758,6864468426306491951)
|
|
|
|
|
|
SELECT * FROM TMember WHERE FNewMemId = 5327350039728720478
|
|
|
|
--
|
|
SELECT * FROM TMemberSaleBill
|
|
WHERE FMemId IN(SELECT FMemId FROM TMember WHERE FNewMemId != 0)
|
|
|
|
|
|
SELECT |