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.
286 lines
7.9 KiB
286 lines
7.9 KiB
|
|
ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100)
|
|
ALTER TABLE TImpMember ADD FMemId BIGINT
|
|
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FName VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FGender INT
|
|
ALTER TABLE TImpMember ADD FCardState INT
|
|
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
|
|
ALTER TABLE TImpMember ADD FCourseId BIGINT
|
|
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FBalance2 DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FRemainTimes INT
|
|
ALTER TABLE TImpMember ADD FPurTimes INT
|
|
ALTER TABLE TImpMember ADD FPurAmount DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FItemId BIGINT
|
|
ALTER TABLE TImpMember ADD FCreateDate DATETIME
|
|
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
|
|
ALTER TABLE TImpMember ADD FCompId BIGINT
|
|
ALTER TABLE TImpMember ADD FCardId BIGINT
|
|
ALTER TABLE TImpMember ADD FMemo VARCHAR(1000)
|
|
ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
|
|
|
|
ALTER TABLE TImpMember ADD FBirthday DATETIME
|
|
ALTER TABLE TImpMember ADD FBirthdayType CHAR
|
|
|
|
|
|
SELECT * FROM TImpMember
|
|
WHERE 卡类别 NOT IN(SELECT FName FROM TMemberCardType)
|
|
|
|
select * from tmembercardtype
|
|
|
|
|
|
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemId IS NULL
|
|
|
|
UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
UPDATE TImpMember SET FMemNo = 会员编号
|
|
UPDATE TImpMember SET FCardno = 卡号
|
|
UPDATE TImpMember SET FName = 姓名
|
|
UPDATE TImpMember SET FMobile = 手机
|
|
UPDATE TImpMember SET FGender = CASE WHEN 性别 = '男' THEN 1 ELSE '0' END
|
|
UPDATE TImpMember SET FBalance = 余额
|
|
UPDATE TImpMember SET FPoint = 积分
|
|
UPDATE TImpMember SET FCreateDate =开卡日期
|
|
UPDATE TImpMember SET FExpiredDate = 到期日期
|
|
|
|
UPDATE TImpMember SET FBirthday = 生日
|
|
|
|
|
|
UPDATE TImpMember SET FBirthdayType = 'G'
|
|
|
|
UPDATE A
|
|
SET A.FCardTypeId = B.FId
|
|
FROM TImpMember AS A,TMemberCardType AS B
|
|
WHERE A.卡类别 = B.FName
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FCompId IS NULL
|
|
|
|
SELECT * FROM TImpMember WHERE 序号 = 346
|
|
|
|
|
|
SELECT * FROM TCompany
|
|
|
|
UPDATE A
|
|
SET A.FCompId = B.FId
|
|
FROM TCompany AS B,TImpMember AS A
|
|
WHERE A.办卡店 = B.FName
|
|
|
|
update TImpMember set FCompId = 5148778370112066439 WHERE 办卡店 = '(空白)'
|
|
update TImpMember set FCompId = 5148778370112066439 WHERE 办卡店 = '国贸店'
|
|
|
|
INSERT INTO TMember(
|
|
FMemId,
|
|
FMemNo,
|
|
FName,
|
|
FBriefCode,
|
|
FTypeId,
|
|
FCompId,
|
|
FCreateDate,
|
|
FGender,
|
|
FBirthdayType,
|
|
FBirthday,FTelephone,FMobilePhone,FQQ,FWeChat,FIdCard,FEmail,FAddress,FProId,FCPW,FQPW,
|
|
FChargeEmpId,FPoint,FRecvConsSMS,FRecvBulkSMS,FMemo,FCustom1,FCustom2,FCustom3,FCustom4,FCustom5)
|
|
SELECT FMemId AS FMemId,
|
|
FMemNo AS FMemNo,
|
|
FName AS FName,
|
|
dbo.FNGetFirstPinYin(FName) as py,
|
|
0 AS FTypeId,
|
|
FCompId AS FCompId,
|
|
MIN(FCreateDate) AS FCreateDate,
|
|
FGender AS FGender,
|
|
FBirthdayType AS FBirthdayType,
|
|
MIN(FBirthday) AS FBirthday,
|
|
'' AS FTelephone,
|
|
ISNULL(FMobile ,'') as FMobile,
|
|
'' AS FQQ,
|
|
'' AS FWeChat,
|
|
'' AS FIdCard,
|
|
'' AS FEmail,
|
|
'' AS FAddress,
|
|
0 AS FProId,
|
|
'' AS FCPW,
|
|
'' AS FQPW,
|
|
0 AS FChargeEmpId,
|
|
MAX(ISNULL(FPoint,0)) AS FPoint,
|
|
1 AS FRecvConsSMS,
|
|
1 AS FRecvBulkSMS,
|
|
'' AS FMemo,
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
|
from TImpMember
|
|
where 会员编号 is not null
|
|
GROUP BY FMemId,FMemNO,FName,FGender,FMobile ,FCompId, FBirthdayType
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FMemNo = FMemNo + 'A' WHERE FMemId = 6573251781542010627
|
|
UPDATE TImpMember SET FMemNo = FMemNo + 'B' WHERE FMemId = 7896940692748214275
|
|
|
|
UPDATE TImpMember SET FCardNo = FCardNo + 'A' WHERE FCardId = 7036012635993014470
|
|
UPDATE TImpMember SET FCardNo = FCardNo + 'B' WHERE FCardId = 6678266536510439391
|
|
|
|
drop table #Member
|
|
|
|
SELECT * FROM TImpMember WHERE FMobile = '18885176741'
|
|
|
|
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FCardId = 6678266536510439391
|
|
|
|
SELECT FMemNo,SUM(1) FROM #Member
|
|
GROUP BY FMemNo
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
SELECT * FROM TImpMember WHERE FMemNO = '18885176741'
|
|
|
|
SELECT 序号 FROM TImpMember WHERE FMemNo IS NULL
|
|
|
|
UPDATE A
|
|
SET A.FMemNo = B.FMemNo,
|
|
A.FName = B.FName,
|
|
A.FGender = B.FGender,
|
|
A.FBirthday = B.FBirthday,
|
|
A.FMobile = B.FMobile,
|
|
A.FBirthdayType = B.FBirthdayType,
|
|
A.FMemId = B.FMemId,
|
|
A.FPoint = B.FPoint
|
|
FROM TImpMember AS A,TImpMember AS B
|
|
WHERE B.序号 = A.序号 - 1
|
|
AND A.FMemNo IS NULL
|
|
|
|
UPDATE TImpMember SET FMemId = dbo.FNNewId()
|
|
|
|
UPDATE A
|
|
SET A.FMobile = B.FMobile
|
|
FROM TImpMember AS A,TImpMember AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
AND A.FMobile IS NULL
|
|
AND B.FMobile is not NULL
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemId,
|
|
A.FCompId = B.FCompId
|
|
FROM TImpMember AS A,(
|
|
|
|
SELECT A.FMemNo,A.FMemId,A.FCompId
|
|
FROM TImpMember AS A,
|
|
(SELECT FMemNo,MIN(序号) AS 序号
|
|
FROM TImpMember
|
|
GROUP BY FMemNo) AS B
|
|
WHERE A.FMemNO = B.FMemNO
|
|
AND A.序号= B.序号
|
|
) AS B
|
|
WHERE A.FMemNo = B.FMemNo
|
|
and A.FMemId != B.FMemId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FMemNo IS NULL
|
|
SELECT * FROM TImpMember WHERE 会员编号 IS NULL
|
|
SELECT * FROM TImpMember WHERE FCardNo IS NULL
|
|
|
|
SELECT A.FMemId FROM TImpMember AS A,TImpMember AS B
|
|
WHERE A.序号 = B.序号 - 1
|
|
AND B.FMemNo IS NULL
|
|
|
|
select * from TImpMember WHERE 姓名= '樊小莉'
|
|
|
|
DROP TABLE TImpMember
|
|
|
|
DROP TABLE TImpMember
|
|
|
|
EXEC sp_helptext PImportMemberData_Init
|
|
|
|
|
|
UPDATE TImpMember SET FCardNo = FMemNo WHERE FCardNO IS NULL
|
|
|
|
ALTER TABLE TImpMember ADD FSeq INT IDENTITY
|
|
ALTER TABLE TImpMember ADD FIndex INT
|
|
|
|
|
|
DROP TABLE #Card
|
|
SELECT FCardNo into #Card
|
|
FROM TImpMember
|
|
|
|
GROUP BY FCardNo
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMember AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
|
|
FROM TImpMember AS A
|
|
WHERE FCardNo IN(SELECT FCardNO FROM #Card)
|
|
|
|
UPDATE TImpMember SET FCardNo = FCardNo + '' + CASE FIndex WHEN 1 THEN 'A' WHEN 2 THEN 'B' WHEN '3' THEN 'C' END
|
|
WHERE FCardNo IN( SELECT FCardNo FROM #Card)
|
|
|
|
SELECT * FROM TImpMember
|
|
WHERE FCardNo LIKE '%A' OR FCARDNo LIKE '%B'
|
|
|
|
SELECT * FROM TImpMEMBER WHERE FCardNo IN(SELECT FCardNo FROM #Card)
|
|
|
|
UPDATE TIMpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '女王卡'),
|
|
FCreateDate = '2018-8-24',FExpiredDate = '2021-8-24'
|
|
WHERE FCardid = 9136439626233109675
|
|
|
|
|
|
SELECT * FROM TImpMEMBER WHERE FCreateDate IS NULL
|
|
|
|
INSERT INTO TMemberCard(
|
|
FCardId,
|
|
FCardNo,
|
|
|
|
FTypeId,
|
|
FValueType,
|
|
FCompId,
|
|
FMemId,
|
|
FState,
|
|
FCreateDate,
|
|
FExpiredDate,
|
|
FTotalTimes,
|
|
FUsedTimes,
|
|
FSaleCompId,
|
|
FSaleBillId,
|
|
FMemo)
|
|
SELECT
|
|
FCardId AS FId,
|
|
FCardNo AS FNo,
|
|
|
|
FCardTypeId AS FTypeId,
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
|
|
FCompId AS FCompId,
|
|
FMemId AS FMemId,
|
|
1 AS FState,
|
|
FCreateDate AS FCreateDate,
|
|
FExpiredDate AS FExpiredDate,
|
|
0 AS FTotalTimes,
|
|
0 AS FUsedTimes,
|
|
FCompId AS FSaleCompId,
|
|
0 AS FSaleBillId,
|
|
ISNULL(FMemo,'') AS FMemo
|
|
FROM TImpMember
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL AS FExpiredDate,''
|
|
FROM TImpMember AS A
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从Excel中导入'
|
|
FROM TImpMember AS A
|
|
|
|
|
|
|
|
|
|
|