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.
203 lines
4.0 KiB
203 lines
4.0 KiB
USE RiZhao_ZuHeFaJi
|
|
|
|
|
|
SELECT FMobilePhone,FName,SUM(1) AS FCount
|
|
INTO TMember_Merge
|
|
FROM TMember
|
|
GROUP BY FMobilePhone,FName
|
|
ORDER BY SUM(1) DESC
|
|
|
|
SELECT * FROM TMergeInfo
|
|
|
|
DELETE TMerge WHERE FCount < 2 OR FMobilePhone = ''
|
|
SELECT * FROM TMergeInfo
|
|
|
|
SP_RENAME 'TMerge','TMergeInfo'
|
|
|
|
SELECT * INTO TMerge
|
|
FROM TMember AS A
|
|
WHERE EXISTS(SELECT 1 FROM TMergeInfo AS B WHERE A.FMobilePhone = B.FMobilePhone AND A.FName = B.FName AND B.FCount > 1 AND B.FMobilePhone != '')
|
|
ORDER BY FMobilePhone
|
|
|
|
|
|
ALTER TABLE TMerge ADD FIndex INT NOT NULL DEFAULT 0
|
|
|
|
UPDATE A
|
|
SET A.FIndex = (SELECT COUNT(1) + 1 FROM TMerge AS B WHERE A.FMobilePhone = B.FMobilePhone AND A.FName = B.FName AND A.FCreateDate > B.FCreateDate)
|
|
FROM TMerge AS A
|
|
|
|
|
|
SELECT * INTO
|
|
|
|
SELECT FName,FMobilePhone ,SUM(1)
|
|
FROM TMerge
|
|
--WHERE FIndex > 2
|
|
WHERE FPhoto IS NOT NULL
|
|
GROUP BY FName,FMObilePhone
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
|
ORDER BY FMobilePhone
|
|
|
|
SELECT * FROM TMerge WHERE FMobilePhone = '18006338303'
|
|
|
|
|
|
ALTER TABLE TMerge ADD FNewMemId BIGINT
|
|
|
|
SELECT * FROM TMemberPhoto
|
|
WHERE FMemId IN(SELECT FMemId FROM TMerge WHERE FIndex = 2)
|
|
OR FMemId IN(SELECT FMemId FROM TMerge WHERE FIndex = 3)
|
|
|
|
ALTER TABLE TMerge ADD FPhoto VARCHAR(111)
|
|
|
|
UPDATE A
|
|
SET A.FPhoto = B.FImagePath
|
|
FROM TMerge AS A,TMemberPhoto AS B
|
|
WHERE A.FMemID = B.FMemId
|
|
|
|
SELECT
|
|
|
|
UPDATE A
|
|
SET A.FNewMemId = B.FMemId
|
|
FROM TMerge AS A,TMerge AS B
|
|
WHERE A.FIndex > 1
|
|
AND B.FIndex = 1
|
|
AND A.FName = B.FName
|
|
AND A.FMobilephone = B.FMobilePhone
|
|
|
|
|
|
|
|
SELECT * FROM TMerge
|
|
ORDER BY FMobilePhone
|
|
|
|
UPDATE A
|
|
SET A.FDeleted = 1,A.FMemo = A.FMemo + '¡¾Öظ´ºÏ²¢É¾³ý¡¿'
|
|
FROM TMember AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCard AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCardAccount AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCardAcctHist AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberPhoto AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
AND B.FMobilePhone NOT IN('17606332002',
|
|
'18006338303')
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberOldTransHist AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberTransHist AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberTransHistPayment AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCourse AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCourseLog AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberArrear AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberArrearEmployee AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TConsumeBill AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberSaleBill AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberRepay AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberCoursePack AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FNewMemId
|
|
FROM TMemberChangeLog AS A,TMerge AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND B.FIndex > 1
|
|
|
|
|
|
SELECT * FROM TMemberArrear WHERE FMemId IN(SELECT FNewMemId FROM TMerge)
|
|
|
|
SELECT * FROM
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM sysobjects WHERE name like 'TMember%'
|
|
|
|
|
|
|