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.
104 lines
2.6 KiB
104 lines
2.6 KiB
USE JiNan_JinZhi
|
|
GO
|
|
|
|
|
|
SELECT * FROM TMember AS A,
|
|
(SELECT * FROM TMember) AS B
|
|
WHERE A.FMobilePhone = B.FMobilePhone
|
|
|
|
SELECT FMobilePhone
|
|
INTO #Mobile
|
|
FROM TMember
|
|
WHERE FMobilePhone NOT IN('','----------','00000000000','-----------')
|
|
GROUP BY FMobilePhone
|
|
HAVING(COUNT(1)) > 1
|
|
|
|
SELECT * FROM TMember WHERE FMobilePhone = '---86601860'
|
|
|
|
--°Ñ¿¨ºÅ´óµÄ£¬ÈÕÆÚ±ä´ó
|
|
UPDATE A
|
|
SET A.FCreateDate = B.FNewCreateDate
|
|
FROM TMember AS A,
|
|
(
|
|
SELECT A.FId,A.FNo,A.FName,A.FMobilePhone,A.FCreateDate,
|
|
DATEADD(s,(SELECT COUNT(1) FROM TMember AS B WHERE B.FMobilePhone = A.FMobilePhone AND A.FNo > B.FNo ),A.FCreateDate) AS FNewCreateDate
|
|
FROM TMember AS A
|
|
WHERE A.FMobilePhone IN(SELECT FMobilePhone FROM #Mobile)
|
|
) AS B
|
|
WHERE A.FId = B.FId
|
|
|
|
--
|
|
SELECT A.FId,A.FNo,A.FName,A.FMobilePhone,A.FCreateDate,
|
|
(SELECT COUNT(1) FROM TMember AS B WHERE B.FMobilePhone = A.FMobilePhone AND A.FCreateDate < B.FCreateDate ) AS FIndex
|
|
INTO #MemberSort
|
|
FROM TMember AS A
|
|
WHERE A.FMobilePhone IN(SELECT FMobilePhone FROM #Mobile)
|
|
ORDER BY FMobilePhone,FNo DESC
|
|
|
|
SELECT * FROM TMember WHERE FMobilePhone = '13011725159'
|
|
|
|
SELECT A.FId AS FParentId,A.FMobilePhone,A.FName, B.FId AS FChildId ,B.FMobilePhone AS FChildMobilePhone,B.FName AS FChildName
|
|
INTO #MemberResult
|
|
FROM
|
|
(
|
|
SELECT * FROM #MemberSort WHERE FIndex = 0
|
|
) AS A,
|
|
(
|
|
SELECT * FROM #MemberSort WHERE FIndex != 0
|
|
) AS B
|
|
WHERE A.FMobilePhone = B.FMobilePhone
|
|
|
|
SELECT * INTO TMemberCard_BAK_20150902
|
|
FROM TMemberCard
|
|
SELECT * INTO TMember_BAK_20150902
|
|
FROM TMember
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCard AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCardAcctHist AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCardOldAcctHist AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberOldTransHist AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCardAcctHist AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCourse AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCourseHist AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FParentId
|
|
FROM TMemberCardAccount AS A,#MemberResult AS B
|
|
WHERE A.FMemId = B.FChildId
|
|
|
|
DELETE TMember WHERE FId IN(SELECT FChildId FROM #MemberResult)
|
|
|
|
SELECT * FROM TMember WHERE FMobilePhone = '13011725159'
|
|
|
|
SELECT * FROM TMember WHERE FPoint > 0
|
|
|
|
SELECT DATEADD(s,1,'2222-01-01 00:00:00')
|
|
|
|
SELECT * FROM TUser |