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.
sql-tools/Import/伊智.sql

811 lines
27 KiB

1 year ago
use XinZhou_YiJing
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
ALTER TABLE TImpMember ADD FPW VARCHAR(200)
ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT
ALTER TABLE TImpMemberCard ADD FCourseId BIGINT
ALTER TABLE TImpMemberCard ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FBalance2 DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FRemainTimes INT
ALTER TABLE TImpMemberCard ADD FPurTimes INT
ALTER TABLE TImpMemberCard ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FItemId BIGINT
ALTER TABLE TImpMemberCard ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCard ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberCard ADD FCardNo VARCHAR(1000)
ALTER TABLE TImpMemberCard ADD FCompId BIGINT
ALTER TABLE TImpMemberCard ADD FCardId BIGINT
ALTER TABLE TImpMemberCard ADD FMemId BIGINT
ALTER TABLE TImpMemberCard ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMemberCard ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMemberCourseItem ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCourseItem ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberCourseItem ADD FCompId BIGINT
ALTER TABLE TImpMemberCourseItem ADD FCardId BIGINT
ALTER TABLE TImpMemberCourseItem ADD FMemId BIGINT
ALTER TABLE TImpMemberCourseItem ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMemberCourseItem ADD FCardTypeId BIGINT
ALTER TABLE TImpMemberCourseItem ADD FItemId BIGINT
ALTER TABLE TImpMemberCourseItem ADD FRemainPurTimes INT
ALTER TABLE TImpMemberCourseItem ADD FPurTimes INT
ALTER TABLE TImpMemberCourseItem ADD FUsedPurTimes INT
ALTER TABLE TImpMemberCourseItem ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCourseItem ADD FRemainFreeTimes INT
ALTER TABLE TImpMemberCourseItem ADD FFreeTimes INT
ALTER TABLE TImpMemberCourseItem ADD FUsedFreeTimes INT
ALTER TABLE TImpMemberCourseItem ADD FFreeAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCourseItem ADD FAdjustPrice DECIMAL(18,6)
ALTER TABLE TImpMemberCoupon ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCoupon ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberCoupon ADD FCompId BIGINT
ALTER TABLE TImpMemberCoupon ADD FCardId BIGINT
ALTER TABLE TImpMemberCoupon ADD FMemId BIGINT
ALTER TABLE TImpMemberCoupon ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMemberCoupon ADD FCardTypeId BIGINT
ALTER TABLE TImpMemberCoupon ADD FItemId BIGINT
ALTER TABLE TImpMemberCoupon ADD FRemainPurTimes INT
ALTER TABLE TImpMemberCoupon ADD FPurTimes INT
ALTER TABLE TImpMemberCoupon ADD FUsedPurTimes INT
ALTER TABLE TImpMemberCoupon ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCoupon ADD FRemainFreeTimes INT
ALTER TABLE TImpMemberCoupon ADD FFreeTimes INT
ALTER TABLE TImpMemberCoupon ADD FUsedFreeTimes INT
ALTER TABLE TImpMemberCoupon ADD FFreeAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCoupon ADD FAdjustPrice DECIMAL(18,6)
SELECT * FROM TImpMemberCard
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FDeptId,FEnabled,FOrder)
SELECT FId =card_id, FNo = NAME,FName = NAME,1,FMaterial = 2,0,FCardFeeAmt = 0,FAcctId = 3,FDeposit = 0,FAcctId2 = 0,FDeposit2 = 0 ,FAcctId3 = 0,FDeposit3 = 0,
FTimes = 0,FAlertBalance = 0,FMinRchgAmt = 0,FSalePointMode = 0,FSalePointValue = 0 ,FRchgPointMode = 0,FRchgPointValue = 0,FPaySmsFee = 0,FTimeCard = 0,FValidityPeriod = 100,FValidityPeriodUnit = 1,
FExpiredDate = NULL,FDefaultMemo = '',FCreateTime = GETDATE(),1,1,FDeptId = 0,FEnabled =1,FOrder = 1
FROM TImpMemberCard
WHERE card_id NOT in(select fid from tmEMBERcARDtYPE)
GROUP BY card_id,name
UPDATE TImpMemberCard SET name = 'B' + name WHERE name = '300<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' AND salon_id = 1349
UPDATE TImpMemberCard SET name = 'A' + name WHERE name = '300<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' AND salon_id = 1351
USE JiNan_MengNiTan
SELECT card_id,NAME
INTO #T
FROM TImpMemberCard
GROUP BY card_id,NAME
SELECT name FROM #T
GROUP BY NAME
HAVING SUM(1) > 1
ORDER BY name
UPDATE
DELETE TMemberCardType WHERE FId > 9
SELECT * FROM TCompany
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
SELECT dbo.FNNewId(),dbo.FNCompId('001'),I.FId,1,1,1
FROM TMemberCardType AS I
WHERE I.FId NOT IN(SELECT FCardTypeId FROM TMemberCardTypeSub)
/*
DELETE TCourse WHERE FItemId IN(SELECT FID from tIMPItem)
DELETE TItem WHERE FId IN(SELECT FID from tIMPItem)
--<EFBFBD><EFBFBD>Ŀ
DROP TABLE TImpItem
SELECT service_num AS id ,dbo.FNNewId() AS FId,service_name AS FName,dbo.FNNewId() AS FCourseId
INTO TImpItem
FROM TImpMemberCourseItem
GROUP BY service_num,service_name
UPDATE TImpItem SET FName = 'δ֪<EFBFBD><EFBFBD>Ŀ'
WHERE FName = ''
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FDisplayTypeId,FPointMode,FPointValue,FDeptId,FAllowBooking,FDisplay)
SELECT FId,FName,FName,FName,FName,0,FBriefCode = dbo.FNGetFirstPinYin(FName),
FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '',
FCustom3 = '',FEnabled = 1,0 ,FVipPrice = 0 ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0,
FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1,FDisplay = 1
FROM TImpItem
SELECT * FROM TItem
WHERE FName IN(SELECT FName FROM TImpItem)
SELECT 'exec sp_rename ' + name + ',' + name + '_1' FROM sysobjects WHERE name LIKE 'TImp%'
exec sp_rename TImpItem_1,TImpItem
exec sp_rename TImpMemberCourseGoods_1,TImpMemberCourseGoods
exec sp_rename TImpMemberCourseItem_1,TImpMemberCourseItem
exec sp_rename TImpMemberExtend_1,TImpMemberExtend
exec sp_rename TImpMemberTransHist,TImpMemberTransHist_1
SELECT SUM(CAST (BALANCE AS FLOAT)) / 100 FROM TImpMemberCard
SELECT * FROM TImpMemberExtend
SELECT SUM(1) FROM TImpMemberCard
SELECT SUM(1) FROM TImpMemberCourse
SELECT id FROM TImpMember
pcopytable 'TImpMemberExtend','TImpMemberExtend_1',''
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT I.FCourseId,
I.FName ,
I.FName ,
dbo.FNGetFirstPinyin(FName) AS FBriefCode,
I.FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
0 AS FTypeId,
1 AS FTimes,
0 AS FFreeTimes,
0 AS FDurable,
0 AS FValidityPeriodUnit,
0 AS FValidityPeriod,
getdate() AS FCreateDate,
NULL AS FExpiredDate,
'' AS FDescription,
1 AS FEnabled,
0 AS FPrice,
0 AS FAmount,
1 AS FCalcMode
FROM TImpItem AS I
SELECT * FROM TImpMemberCourse WHERE mem_id = 2685182&
*/
/* <EFBFBD>Ż<EFBFBD>ȯ<EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
--<EFBFBD><EFBFBD>Ŀ
DROP TABLE TImpItem
select COUPON from TImpMemberCoupon
group by coupon
update TImpMemberCoupon set coupon_name = '4574<EFBFBD><EFBFBD>Ⱦȯ2' WHERE coupon_id = 4574
update TImpMemberCoupon set coupon_name = '3709<EFBFBD><EFBFBD>Ⱦȯ' WHERE coupon_id = 3709
update TImpMemberCoupon set coupon_name = '9488<EFBFBD><EFBFBD>Ⱦȯ2' WHERE coupon_id = 9488
update TImpMemberCoupon set coupon_name = '3714<EFBFBD><EFBFBD>Ⱦȯ' WHERE coupon_id = 3714
SELECT coupon_id AS id ,dbo.FNNewId() AS FId,coupon_name AS FName,dbo.FNNewId() AS FCourseId
INTO TImpItemEx
FROM TImpMemberCoupon
GROUP BY coupon_id,coupon_name
UPDATE TImpItem SET FName = 'δ֪<EFBFBD><EFBFBD>Ŀ'
WHERE FName = ''
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FDisplayTypeId,FPointMode,FPointValue,FDeptId,FAllowBooking,FDisplay)
SELECT FId,FName,FName,FName,FName,0,FBriefCode = dbo.FNGetFirstPinYin(FName),
FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '',
FCustom3 = '',FEnabled = 1,0 ,FVipPrice = 0 ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0,
FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1,FDisplay = 1
FROM TImpItemEx
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT I.FCourseId,
I.FName ,
I.FName ,
dbo.FNGetFirstPinyin(FName) AS FBriefCode,
I.FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
0 AS FTypeId,
1 AS FTimes,
0 AS FFreeTimes,
0 AS FDurable,
0 AS FValidityPeriodUnit,
0 AS FValidityPeriod,
getdate() AS FCreateDate,
NULL AS FExpiredDate,
'' AS FDescription,
1 AS FEnabled,
0 AS FPrice,
0 AS FAmount,
1 AS FCalcMode
FROM TImpItemEx AS I
*/
SELECT * FROM TImpMember WHERE FCourseIsLoad = 0
UPDATE TImpMember SET FMemId = id
UPDATE TImpMember SET FName = name
UPDATE TImpMember SET FMobile = handset
UPDATE TImpMember SET FGender = CASE WHEN gender = '1' THEN 1 ELSE 0 END
UPDATE TImpMember SET FBirthday = birthday WHERE birthday != ''
UPDATE TImpMember SET FBirthdayType = case when birthday_type != 1 THEN 'L' ELSE 'G' END
UPDATE TImpMember SET FCreateDate = created_at
SELECT * FROM TImpMEMBER WHERE handset = '18615631987'
UPDATE TImpMemberCourseItem SET FCompId = dbo.FNCompId('001') WHERE salon_id = 1351
UPDATE TImpMemberCourseItem SET FCompId = dbo.FNCompId('002') WHERE salon_id = 1349
SELECT * FROM TCompany
SELECT salon_id FROM TImpMemberCard
GROUP BY salon_id
UPDATE TImpMember SET FPoint = 0
UPDATE TImpMember SET FPW = ''
UPDATE TImpMember SET FPW = 'MD5-' + password WHERE password != ''
UPDATE TImpMember SET FMemo = remark
SELECT * FROM TImpMemberExtend
SELECT * FROM TImpMember WHERE FMobile = '18763999573 '
SELECT member_card_num FROM TImpMemberCard
GROUP BY member_card_num
HAVING SUM(1) > 1
SELECT * FROM TImpMemberCard WHERE member_card_num = '00002'
UPDATE A
SET A.FMemNo = B.FCardNo
FROM TImpMemberCard AS B,TImpMember AS A,(SELECT member_Id,MIN(create_date) AS create_date FROM TImpMemberCard GROUP BY member_Id) AS C
WHERE A.id = B.member_Id
AND B.member_Id = C.member_Id
AND B.create_date = C.create_date
UPDATE TImpMember SET FMemNO = FMobile WHERE ISNULL(FMemNo,'') = ''
UPDATE TImpMember SET FMemNo = ''
SELECT * FROM TImpMemberCard
SELECT * FROM TImpMember WHERE id not in(SELECT member_id FROM TImpMemberCard)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberCard SET FCardTypeId = card_id
--<EFBFBD><EFBFBD>ID
SELECT
UPDATE TImpMemberCard SET FCardId = id
--<EFBFBD><EFBFBD>ԱID
UPDATE TImpMemberCard SET FMemId = member_id
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberCard SET FCardNO = member_card_num
SELECT salon_id FROM TImpMemberCard
GROUP BY salon_id
SELECT FCardNo FROM TImpMemberCard
GROUP BY FCardNo
HAVING SUM(1) > 1
UPDATE TImpMemberCard SET FCardNo = 'A' + FCardNo WHERE FCardNo IN(SELECT FCardNo FROM #Card )
AND salon_id = 1351
UPDATE TImpMemberCard SET FCardNo = 'B' + FCardNo WHERE FCardNo IN(SELECT FCardNo FROM #Card )
AND salon_id = 1349
UPDATE TImpMemberCard SET FCreateDate = create_date
UPDATE TImpMemberCard SET FExpiredDate = expiry_date
UPDATE TImpMemberCard SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) WHERE FExpiredDate IS null OR FExpiredDate = '1900-01-01'
UPDATE TImpMemberCard SET FBalance = cast(balance as float)/ 100.0
UPDATE TImpMemberCard SET FBalance2 = cast(gift_balance as float)/ 100.0
UPDATE TImpMemberCard SET FArrear = 0
SELECT SUM(FBalance) FROM TImpMemberCard
SELECT SUM(cast(Balance as float)) FROM TImpMemberCard
--<EFBFBD>Ƴ<EFBFBD>
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMemberCourseItem
SELECT * FROM TImpMemberCard
SELECT * FROM TImpMember WHERE id = 1540892
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMemberCourseItem
SELECT * FROM TImpMemberCourseGoods
SELECT * FROM TImpMemberCourseItem
WHERE member_course_id = 204232
SELECT * FROM TImpMemberCourse
WHERE member_id = 1540892
SELECT * FROM TImpMember WHERE FMobile = '15562259939 '
DROP TABLE TImpMemberCourse
UPDATE A
SET A.FMemId = B.member_id,
A.FCardId = A.Id
FROM TImpMemberCourseItem AS A,TImpMemberCourse AS B
WHERE A.member_course_id = B.id
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SELECT * FROM TImpMemberCourseItem
UPDATE TImpMemberCourseItem SET FPurTimes = 0,FRemainPurTimes = 0,FUsedPurTimes = 0,FPurAmount = 0
UPDATE TImpMemberCourseItem SET FFreeTimes = 0,FRemainFreeTimes = 0,FUsedFreeTimes = 0,FFreeAmount = 0
UPDATE TImpMemberCourseItem SET FAdjustPrice = price / 100
UPDATE TImpMemberCourseItem SET FPurTimes = counts
UPDATE TImpMemberCourseItem SET FRemainPurTimes = balance
UPDATE TImpMemberCourseItem SET FUsedPurTimes = FPurTimes - FRemainPurTimes
UPDATE TImpMemberCourseItem SET FPurAmount = FPurTimes * FAdjustPrice
UPDATE TImpMemberCourseItem SET FFreeTimes = 0
UPDATE TImpMemberCourseItem SET FRemainFreeTimes = 0
UPDATE TImpMemberCourseItem SET FUsedFreeTimes = 0
UPDATE TImpMemberCourseItem SET FFreeAmount = 0
UPDATE TImpMemberCourseItem SET FCompId = dbo.FNCompId('001') WHERE
UPDATE A
SET A.FCompId = B.FCompId
FROM TImpMemberCourseItem AS A,TImpMember AS B,TImpMemberCourse AS C
WHERE C.member_id = B.id
AND A.member_course_id = c.id
SELECT * FROM TImpMemberCourseItem
UPDATE A
SET A.FCreateDate = b.created_date,
A.FExpiredDate = b.expiry_date
FROM TImpMemberCourseItem AS A,TImpMemberCourse AS B
WHERE A.member_course_id = b.id
UPDATE TImpMemberCourseItem SET FExpiredDate = NULL WHERE FExpiredDate = '1900-01-01 00:00:00.000'
UPDATE A
SET A.FItemId = B.FId,
A.FCardTypeId = B.FCourseId
FROM TImpMemberCourseItem AS A,TImpItem AS B
WHERE A.service_num = B.id
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),
0 AS FTypeId,
FCompId AS FCompId,
ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate,
FGender AS FGender,
FBirthdayType AS FBirthdayType,
FBirthday AS FBirthday,
'' AS FTelephone,
ISNULL(FMobile,'') AS FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
FPW AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
ISNULL( FPoint,0) AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
ISNULL(FMemo,'') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
WHERE FMemId IN(SELECT FMemId FROM TImpMemberCourseItem)
AND FMemId NOT IN(SELECT FMemId FROM TMember)
SELECT * FROM TMember WHERE FMemNO = '000002'
SELECT * FROM TImpMember WHERE FMemNO = '000002'
SELECT * FROM TMember
SELECT * FROM TImpMemberCard WHERE FCardNo = '000002'
SELECT * FROM TImpMemberCard_1 WHERE FCardNo = '000002'
UPDATE TImpMemberCard SET FCardNo = 'A' + FCardNo WHERE FCardNo = '000002'
UPDATE TImpMemberCard_1 SET FCardNo = 'B' + FCardNo WHERE FCardNo = '000002'
UPDATE TImpMember SET FMemNo = 'A' + FMemNo WHERE FMemNo = '000002'
UPDATE TImpMember_1 SET FMemNo = 'B' + FMemNo WHERE FMemNo = '000002'
SELECT * FROM TImpMember WHERE FMemNO = '18561111190'
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FCardNo AS FNo,
FCardNo AS FFaceNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
1 AS FState,
FCreateDate AS FCreateDate,
ISNULL(FExpiredDate,DATEADD(YEAR,100,FCreateDate)) AS FExpiredDate,
ISNULL(FRemainTimes,0) AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
ISNULL('','') AS FMemo
FROM TImpMemberCard
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,ISNULL(A.FArrear,0),FCreateDate,NULL AS FExpiredDate,''
FROM TImpMemberCard 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,A.FArrear,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMemberCard AS A
--<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,ISNULL(A.FArrear,0),FCreateDate,NULL AS FExpiredDate,''
FROM TImpMemberCard AS A
WHERE 1=1
AND FBalance2 != 0
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,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,A.FArrear,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMemberCard AS A
WHERE 1=1
AND FBalance2 != 0
DELETE TMemberCourse WHERE FId > 0
DELETE TMemberCourseLog WHERE FId > 0
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,FAdjustPrice
FROM TImpMemberCourseItem AS A
WHERE member_course_id IN(
SELECT id FROM TImpMemberCourse
WHERE salon_name = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,FAdjustPrice
FROM TImpMemberCourseItem AS A
WHERE FMemId NOT IN(SELECT FMemId FROM TMember)
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime)
SELECT dbo.FNNewId(),FMemId,A.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,FFreeTimes,FUsedPurTimes,FUsedFreeTimes,FCompId,'DR','Import',0,'',0,getdate()
FROM TImpMemberCourseItem AS A
WHERE member_course_id IN(
SELECT id FROM TImpMemberCourse
WHERE salon_name = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
--ȯ
SELECT * FROM TImpMemberCoupon WHERE expiry_date > '' and expiry_date < '2022-08-20'
select * from TImpMemberCoupon WHERE consume_status != 1
select * from TImpMember WHERE handset = '18234149031'
UPDATE TImpMemberCoupon SET FMemId = customer_id
UPDATE TImpMemberCoupon SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMemberCoupon SET FPurTimes = 0,FRemainPurTimes = 0,FUsedPurTimes = 0,FPurAmount = 0
UPDATE TImpMemberCoupon SET FFreeTimes = 0,FRemainFreeTimes = 0,FUsedFreeTimes = 0,FFreeAmount = 0
UPDATE TImpMemberCoupon SET FAdjustPrice = 0
UPDATE TImpMemberCoupon SET FPurTimes = 1
UPDATE TImpMemberCoupon SET FRemainPurTimes = 0 where consume_status != 0
UPDATE TImpMemberCoupon SET FRemainPurTimes = 1 where consume_status = 0
UPDATE TImpMemberCoupon SET FUsedPurTimes = FPurTimes - FRemainPurTimes
UPDATE TImpMemberCoupon SET FPurAmount = 0
UPDATE TImpMemberCoupon SET FFreeTimes = 0
UPDATE TImpMemberCourseItem SET FRemainFreeTimes = 0
UPDATE TImpMemberCoupon SET FUsedFreeTimes = 0
UPDATE TImpMemberCoupon SET FFreeAmount = 0
UPDATE TImpMemberCoupon SET FCreateDate = created_at
UPDATE TImpMemberCoupon SET FExpiredDate = null
UPDATE TImpMemberCoupon SET FExpiredDate = expiry_date where expiry_date != ''
UPDATE TImpMemberCoupon SET FCompId = dbo.FNCompId('001') WHERE salon_id = 2217
UPDATE TImpMemberCoupon SET FCompId = dbo.FNCompId('002') WHERE salon_id = 3068
select salon_id ,sum(1) from tIMpmEMBER GROUP BY SALON_ID
UPDATE A
SET A.FItemId = B.FId,
A.FCardTypeId = B.FCourseId
FROM TImpMemberCoupon AS A,TImpItemEx AS B
WHERE A.coupon_id = B.id
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,FAdjustPrice
FROM TImpMemberCoupon AS A
WHERE consume_status = 1
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime)
SELECT dbo.FNNewId(),FMemId,A.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,FFreeTimes,FUsedPurTimes,FUsedFreeTimes,FCompId,'DR','Import',0,'',0,getdate()
FROM TImpMemberCoupon AS A
WHERE consume_status = 1
select * from TImpMember
WHERE id in(select customer_id from TImpMemberCoupon where consume_status = 1)
select * from TImpMemberCoupon where expiry_date < '2022-08-30' and expiry_date > ''
and salon_id != 3068
select * from TImpMemberCoupon where customer_id = 6601380
select * from TImpMember WHERE HANDSET = '13835067705'
select * from TImpMember WHERE id = 6601380
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
SELECT * FROM TImpMember WHERE FMemId NOT IN(SELECT FMemId FROM TImpMemberTransHist)
SELECT * FROM TImpMemberTransHist
ALTER TABLE TImpMemberTransHist ADD FMemId BIGINT
ALTER TABLE TImpMemberTransHist ADD FCompId BIGINT
ALTER TABLE TImpMemberTransHist ADD FPayments VARCHAR(1000)
ALTER TABLE TImpMemberTransHist ADD FAmount FLOAT
ALTER TABLE TImpMemberTransHist ADD FContent VARCHAR(1000)
SELECT * FROM TImpMemberTransHist
UPDATE TImpMemberTransHist SET FCompId = dbo.FNCompId('001') where salon_id = 1351
UPDATE TImpMemberTransHist SET FCompId = dbo.FNCompId('002') where salon_id = 1349
UPDATE TImpMemberTransHist SET FCompId = 0 WHERE salon_id not in(1351,1349)
SELECT salon_id FROM TImpMemberTransHist
GROUP BY salon_id
SELECT * FROM TImpMemberTransHist
WHERE member_id IN(SELECT id FROM TImpMember_1)
SELECT id FROM TImpMember
ORDER BY id
SELECT salon_id, COUNT(1) FROM TImpMember
WHERE id NOT IN(SELECT member_id FROM TImpMemberTransHist WITH(NOLOCK))
GROUP BY salon_id
SELECT * FROM qingdao_jinxuanlong_old..TMemberTransHist
SELECT * FROM TImpMemberCard WHERE member_id = 2051010
UPDATE TImpMemberTransHist SET FMemId = member_Id
SELECT * FROM TImpMember WHERE FName like '%<EFBFBD>ſ<EFBFBD>%'
UPDATE TImpMemberTransHist SET FContent = REPLACE(show,'<span style="color:#20a0ff">','')
UPDATE TImpMemberTransHist SET FContent = REPLACE(FContent,'</span>','')
UPDATE TImpMemberTransHist SET FContent = REPLACE(FContent,'<span style="color:#20a0ff">','')
UPDATE TImpMemberTransHist SET FPayments = SUBSTRING(FContent,CHARINDEX('ʹ<EFBFBD><EFBFBD>',FContent),LEN(FContent))
UPDATE TImpMemberTransHist SET FContent = SUBSTRING(FContent,1,CHARINDEX('ʹ<EFBFBD><EFBFBD>',FContent) - 1)
WHERE CHARINDEX('ʹ<EFBFBD><EFBFBD>',FContent) - 1 > 1
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT dbo.FNNewId(),A.FMemId,A.created_at,0,A.FCompId,'DR',behavior_type_name,salon_code,FContent,0,1,0,FPayments,'',''
FROM TImpMemberTransHist AS A
drop table _TransHist
SELECT * INTO _TransHist FROM qingdao_jinxuanlong_old..TMemberTransHist
ALTER TABLE _TransHist ADD FNewMemId BIGINT
UPDATE A
SET A.FNewMemId = B.FMemId
FROM _TransHist AS A,TMember AS B,qingdao_jinxuanlong_old..TMember AS C
WHERE B.FMobilePhone = C.FMobilePhone
AND B.FName = C.FName
AND A.FMemId = C.FMemId
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT FId,FNewMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContentText,FDctPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo
FROM _TransHist
WHERE FNewMemId IS NOT NULL
SELECT * FROM TMemberTr
WHERE FMemId IS NULL
SELECT * FROM TImpMemberTransHist AS A
WHERE FMemId IS NULL
SELECT COUNT(1) FROM TIMPMember WHERE id IN(SELECT mem_id FROM TImpMemberCardDate)
SELECT COUNT(1) FROM TIMPMember WHERE id IN(SELECT member_id FROM TImpMemberCard)
or id IN(SELECT mem_id FROM TImpMemberCourse)
SELECT * FROM TImpMember WHERE FMemId = 6124342
SELECT mem_id FROM TImpMemberCardDate
WHERE mem_id nOT IN(SELECT id FROM TIMpMember)
GROUP BY mem_id
SELECT * FROM TImpMemberCardDate WHERE mem_id NOT IN(SELECT member_id FROM TImpMemberCard )
AND mem_id NOT IN(SELECT mem_id FROM TImpMemberCourse )
SELECT * FROM TImpMember WHERE id = 4052598
SELECT * FROM TImpMember WHERE id = 5635652
SELECT * FROM TMember WHERE FCPW != ''
AND FCPW NOT LIKE 'MD%'
select * from TImpMemberExtend_1
WHERE member_id = 1541624
OR debt_amount > 0
select * from TImpMemberExtend_1
WHERE debt_amount > 0
use JiNan_MengNiTan
SELECT * FROM sysobjects where name like 'TImp%'
SELECT * FROM TImpMember_1 WHERE id = 34937
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƷǷ<EFBFBD><EFBFBD>
ALTER TABLE TImpMemberExtend ADD FMemId BIGINT
ALTER TABLE TImpMemberExtend ADD FCompId BIGINT
ALTER TABLE TImpMemberExtend ADD FArrear DECIMAL(18,6)
UPDATE A
SET A.FMemId = B.FMemId,
A.FCompId = B.FCompId
FROM TImpMemberExtend AS A,TImpMember AS B
WHERE A.member_id = B.id
UPDATE TImpMemberExtend SET FArrear = debt_amount / 100
INSERT TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid)
SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'DR_ItemGoods',0,'DR_XF','DR_Consume',0,'',0,0,FArrear,0,0
FROM TImpMemberExtend AS A
WHERE A.FArrear > 0
select * from TImpMemberExtend