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

853 lines
28 KiB

use JiNan_FeiFan
SELECT * FROM TImpMemberPack
SELECT * FROM sysobjects WHERE name LIKE 'TiMP%'
SELECT * FROM TImpMember WHERE MemberCode = '00461'
SELECT * FROM TImpMember WHERE MemberCode = '00461'
SELECT * FROM TImpMemberPack WHERE FMemId = 5297001
SELECT COUNT(1) FROM TImpMemberAcct
SELECT * FROM TImpMemberAcct
WHERE intPackageId = '86375'
ALTER TABLE TImpMemberPack ADD FAdjustPrice DECIMAL(18,6)
ALTER TABLE TImpMemberPack ADD FPurAmount DECIMAL(18,6)
UPDATE A
SET A.FAdjustPrice = CAST(B.decMoneySurplus2 AS DECIMAL(18,6))/ decTimeSurplus2,
A.FPurAmount = decTimeSurplus2
FROM TImpMemberPack AS A,TImpMemberAcct AS B
WHERE decTimeSurplus2 >0
AND A.intId = B.intPackageId
UPDATE A
SET A.FAdjustPrice = B.FAdjustPrice
FROM TImpMemberPack AS B,TMemberCourse AS A
WHERE A.fiD = B.FMemCourseId
AND B.FAdjustPrice is not null
drop table TImpMemberAcct
UPDATE TImpMember SET FIsLoad = 0
SELECT count(*) FROM TImpMember WHERE ID NOT IN(SELECT FCardId FROM TImpMemberAcct)
SELECT * FROM TImpMemberAcct
WHERE 1=1
AND intAccountCate != 1
DROP TABLE TImpMemberAcct
SELECT * FROM sysobjects WHERE name LIKE 'TImp%'
SELECT * FROM TImpMemberCard
CREATE TABLE TImpError
(
CardId BIGINT,
Error VARCHAR(7000)
)
SELECT * FROM TImpError
ALTER TABLE TImpMember ADD FIsLoad BIT NOT NULL DEFAULT 0
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 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 FUsedPurTimes DECIMAL(18,6)
ALTER TABLE TImpMember ADD FAdjustPrice DECIMAL(18,6)
ALTER TABLE TImpMember ADD FBirthday DATETIME
ALTER TABLE TImpMember ADD FBirthdayType CHAR
UPDATE TImpMember SET FMemId = MemberId
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemId = 0
UPDATE TImpMember SET FCardId = ID
UPDATE TImpMember SET FMemNo = Cardno
UPDATE TImpMember SET FCardno = Cardno
UPDATE TImpMember SET FName = MemberName
UPDATE TImpMember SET FMobile = MobilePhone
UPDATE TImpMember SET FGender = CASE WHEN Sex = '<EFBFBD><EFBFBD>' THEN 1 ELSE '0' END
UPDATE TImpMember SET FBalance = CAST(Balance AS FLOAT)
UPDATE TImpMember SET FRemainTimes = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FPurTimes = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FPurAmount = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FCreateDate = CreateTime
UPDATE TImpMember SET FCompId = (SELECT FId FROM TCompany WHERE FNo = '007')
UPDATE TImpMember SET FArrear = CAST(decMoneySurplus AS FLOAT)
UPDATE TImpMember SET FMemo = remark
UPDATE TImpMember SET FPoint = cast(JF as float)
UPDATE TImpMember SET FPoint = 0
UPDATE TImpMember SET FCardState = 0
--<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
SELECT * FROM TImpMemberCard WHERE LiftTerminateTime != ''
UPDATE A
SET A.FExpiredDate = B.LiftTerminateTime
FROM TIMpMember AS A,TImpMemberCard AS B
WHERE A.FCardId = B.Id
AND LiftTerminateTime > '1753-01-01'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DROP TABLE TImpCardType
GO
CREATE TABLE TImpCardType
(
FShopId INT ,
FCardTypeName VARCHAR(500),
FCardTypeNo VARCHAR(50),
FCardTypeId BIGINT
)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FCardTypeName = CardTypeName + '[' +CAST(Discount * CAST(10.0 AS FLOAT) AS VARCHAR) + '<EFBFBD><EFBFBD>]'
FROM TImpMember AS A
INSERT TImpCardType(FCardTypeId,FCardTypeNo,FCardTypeName)
SELECT dbo.FNNewId(),
FCardTypeName ,
FCardTypeName AS A
FROM TImpMember
WHERE SaleType = 1
GROUP BY FCardTypeName
ORDER BY FCardTypeName
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 =FCardTypeId, FCardTypeNo,FCardTypeName,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 TImpCardType
WHERE FCardTypeNo NOT IN(SELECT FNO FROM TMemberCardType)
ORDER BY FCardTypeName
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
SELECT dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled
FROM TMemberCardType AS I,TCompany AS C
WHERE I.FId > 1
AND C.FId != 0
AND C.FNo IN( '007','001')
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
UPDATE A SET A.FCardTypeId = B.FCardTypeId
FROM TImpMember AS A,TImpCardType AS B
WHERE A.FCardTypeName = B.FCardTypeName
--
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FBirthday = NULL
UPDATE TImpMember SET FBirthdayType = 'G'
UPDATE TImpMember SET FBirthdayType = 'L' WHERE IsCNBirth = 1
ALTER TABLE TImpMember ADD FBirthdayStr VARCHAR(10)
UPDATE TImpMember SET FBirthdayStr = REPLACE(Birth,' ','')
UPDATE TImpMember SET FBirthdayStr = REPLACE(REPLACE(FBirthdayStr,'0000','9999'),'1111','9999')
UPDATE TImpMember SET FBirthdayStr = '9999-11-11' WHERE FBirthdayStr = '1-11-11'
UPDATE TImpMember SET FBirthdayStr = '' WHERE FBirthdayStr = '9999-11-11'
UPDATE TImpMember SET FBirthdayStr = '9999-11-11' WHERE FBirthdayStr = '11-11-11'
UPDATE TImpMember SET FBirthdayStr = '9999-11-11' WHERE FBirthdayStr = '111-11-11'
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'006','996')
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'007','997')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'008','998')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'097','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'098','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'099','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'095','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'1000','9999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'0-','9999-') WHERE FBirthdayStr = '0-12-04'
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-1-','-01-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-2-','-02-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-3-','-03-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-4-','-04-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-5-','-05-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-6-','-06-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-7-','-07-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-8-','-08-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-9-','-09-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-9','-09') WHERE FBirthdayStr LIKE '%-9' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-1','-01') WHERE FBirthdayStr LIKE '%-1' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-2','-02') WHERE FBirthdayStr LIKE '%-2' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-3','-03') WHERE FBirthdayStr LIKE '%-3' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-4','-04') WHERE FBirthdayStr LIKE '%-4' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-5','-05') WHERE FBirthdayStr LIKE '%-5' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-6','-06') WHERE FBirthdayStr LIKE '%-6' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-7','-07') WHERE FBirthdayStr LIKE '%-7' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-8','-08') WHERE FBirthdayStr LIKE '%-8' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = '' where FBirthdayStr ='9999-73-06'
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'000','9999')where len(FBirthdayStr) = len('000-02-17')
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'001','9999')where len(FBirthdayStr) = len('000-02-17')
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'001','9999')where len(FBirthdayStr) = len('000-02-17')
UPDATE TImpMember SET FBirthdayStr ='19' + FBirthdayStr where len(FBirthdayStr) = len('87-09-29')
UPDATE TImpMember SET FBirthdayStr ='9999' + FBirthdayStr where FBirthdayStr like '-%'
UPDATE TImpMember SET FBirthdayStr ='19' + FBirthdayStr where len(FBirthdayStr) = len('84-5-25') AND FBirthdayStr > '5'
UPDATE TImpMember SET FBirthdayStr ='999' + FBirthdayStr where len(FBirthdayStr) = len('0-01-04')
UPDATE TImpMember SET FBirthdayStr ='9999' + replace(FBirthdayStr,' ','')
where replace(FBirthdayStr,' ','') like '-%'
UPDATE TImpMember SET FBirthdayStr = '' WHERE FBirthdayStr LIKE '%-76-%'
UPDATE TImpMember SET FBirthdayStr = replace(FBirthdayStr,'0001-','9999-') WHERE FBirthdayStr LIKE '0001-%'
UPDATE TImpMember SET FBirthdayStr = replace(FBirthdayStr,'0200-','9999-') WHERE FBirthdayStr LIKE '0200-%'
UPDATE TImpMember SET FBirthdayStr = replace(FBirthdayStr,'0969-','9999-') WHERE FBirthdayStr LIKE '0969-%'
UPDATE TImpMember SET FBirthdayStr = replace(FBirthdayStr,'1500-','9999-') WHERE FBirthdayStr LIKE '1500-%'
UPDATE TImpMember SET FBirthdayStr = '9996-02-29'
WHERE 1=1
AND FBirthdayStr LIKE '%02-29' OR FBirthdayStr LIKE
AND FBirthdayType = 'L'
SELECT FBirthdayStr FROM TImpMember WHERE FBirthdayStr LIKE '___-__-__'
UPDATE TImpMember SET FBirthdayStr = '9999' + SUBSTRING(FBirthdayStr,4,6) WHERE FBirthdayStr LIKE '___-__-__'
SELECT FBirthdayStr ,FBirthdayType
-- ,CAST(FBirthdayStr AS DATETIME)
FROM TImpMember
WHERE 1=1
AND LEN(FBirthdayStr) = 10
AND FBirthdayStr > '9999-12-31'
AND FBirthdayStr != ''
ORDER BY FBirthdayStr ASC
SELECT FBirthdayStr FROM TImpMember
UPDATE TImpMember SET FBirthday = FBirthdayStr
WHERE LEN(FBirthdayStr) = 10
SELECT Birth FROM TImpMember
WHERE LEN(Birth) = 10
AND Birth NOT LIKE '00%'
SELECT Birth FROM TImpMember
--״̬
UPDATE TMemberCardAccount SET FExpiredDate = null
SELECT * FROM TImpMember WHERE StatusReason NOT IN('<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD>ʧ','<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpMember SET FCardState = 1
UPDATE TImpMember SET FCardState = 1 WHERE StatusReason = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET FCardState = 1 WHERE StatusReason = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET FCardState = 16 WHERE StatusReason = '<EFBFBD><EFBFBD>ʧ'
UPDATE TImpMember SET FCardState = 1 WHERE StatusReason = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
--<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SELECT FMemNo,SUM(1) FROM TIMpMEMBER
GROUP BY FMemNo
ORDER BY SUM(1) DESC
SELECT FCardnO,SUM(1) FROM TIMpMEMBER
GROUP BY FCardnO
ORDER BY SUM(1) DESC
ALTER TABLE TImpMember ADD FSeq INT IDENTITY(1,1)
ALTER TABLE TImpMember ADD FIndex INT NOT NULL DEFAULT 0
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
SELECT * FROM TImpMember WHERE FIndex > 1
UPDATE TImpMember SET FCardNo = 'V' + FCardNo
WHERE FCardNo IN(SELECT FMemNo FROM TMember)
WHERE FMemId IN
(SELECT FMemId FROM TImpMember WHERE FIndex > 1)
UPDATE TImpMember SET FMemNo = FCardNo
SELECT * FROM TImpMember WHERE FMemNo IN(SELECT FMemNO FROM TMember)
--<EFBFBD>ŵ<EFBFBD>
use jinan_xiu
SELECT * FROM TCompany
UPDATE A
SET A.FCompId = C.FId
FROM TCompany AS C,TImpMember AS A
WHERE C.FAddress = A.ShopName
SELECT ShopId,ShopName FROM TImpMember
GROUP BY ShopId,ShopName
UPDATE TImpMemberCard SET FCompId = dbo.FNCompId('007'
)
SELECT * FROM TCompany
SELECT ShopName,ShopId,FCompId FROM TImpMember
GROUP BY ShopName,FCompId,ShopId
UPDATE TImpMember SET FCompId = dbo.FNCompId('002') WHERE ShopId = 43623
UPDATE TImpMember SET FCompId = dbo.FNCompId('003') WHERE ShopId = 53863
--<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
SELECT * FROM TImpMember WHERE saleType = 2
select dbo.FNNewId() AS FId, dbo.FNNewId() AS FCourseId, 'WD_' + cardTypeName AS FNo, cardTypeName AS FName
INTO TImpItem
from TImpMember
WHERE saleType = 2
GROUP BY cardTypeName
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking)
SELECT FId,FNo,FName,FName,FName,0,dbo.FNGetFirstPinYin(FName),'',1,1,1,'','','',1,0,0,0,0,0,0,0,0
FROM TImpItem
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FCourseId AS FId,
I.FNo + 'L1',
I.FName + '-' + '<EFBFBD>Ƴ<EFBFBD>1' AS FName,
'' AS FBriefCode,
I.FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') 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
ALTER TABLE TImpMember ADD FAdjustPrice DECIMAL(18,6)
--<EFBFBD>Ƴ<EFBFBD>ID
UPDATE A
SET A.FCourseId = B.FCourseId,
A.FItemId = B.FId
FROM TImpItem AS B,TImpMember as a
WHERE A.CardTypeName = B.FName
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FPurAmount =CAST( TimeMOney AS FLOAT)
UPDATE TImpMember SET FPurTimes = TimeRate
UPDATE TImpMember SET FRemainTimes = Time
UPDATE TImpMember SET FAdjustPrice = FPurAmount / FPurTimes WHERE FPurTimes > 0
SELECT * FROM TImpMember WHERE saleType = 2 AND FExpiredDate IS NULL
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCardId,FMemId,FCourseId,0,FItemId,FCompId,FPurTimes,ISNULL(FPurAmount,0),0,FPurTimes - FRemainTimes,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD>ƺƵ<EFBFBD><EFBFBD><EFBFBD>',1,ISNULL(FAdjustPrice,0)
FROM TImpMember
--WHERE FCourseId IS NOT NULL
WHERE saleType = 2
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),FMemId,FCardId,0,FCourseId,FTime = getdate(),FPurTimes,FPurTimes - FRemainTimes,0,0,
FCompId,
'DR','Import',0,'',0
FROM TImpMember
WHERE saleType = 2
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
SELECT * FROM TImpMemberLog
ALTER TABLE TImpMemberLog ADD FMemId BIGINT
ALTER TABLE TImpMemberLog ADD FBillNo VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FBizType VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FContent VARCHAR(1000)
ALTER TABLE TImpMemberLog ADD FAmount DECIMAL(18,6)
ALTER TABLE TImpMemberLog ADD FTime DATETIME
ALTER TABLE TImpMemberLog ADD FId VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FEmployee VARCHAR(1000)
ALTER TABLE TImpMemberLog ADD FQuantity DECIMAL(18,6)
ALTER TABLE TImpMemberLog ADD FCompId BIGINT
UPDATE A
SET A.FMemId = M.FMemId
FROM TImpMemberLog AS A,TMember AS M
WHERE A.<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = M.FMemNo
SELECT * FROM TImpMemberAcctHist
UPDATE TImpMemberLog SET FBillNo = <EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>
UPDATE TImpMemberLog SET FContent = <EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FQuantity = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FAmount = <EFBFBD>ۿ۽<EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FEmployee = ISNULL(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>,'')
UPDATE TImpMemberLog SET FTime = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FQuantity = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FId = dbo.FNNewId()
UPDATE TImpMemberLog SET FCompId = (SELECT FId FROM TCompany WHERE FNo = '003')
ALTER TABLE TMember ALTER COLUMN FMobilePhone VARCHAR(50)
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,
MIN(FMemNo) AS FMemNo,
FName AS FName,
dbo.FNGetFirstPinYin(FName) AS Code,
0 AS FTypeId,
MIN(FCompId) AS FCompId,
MIN(FCreateDate) 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,
'' AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
'' AS FMemo,
'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
WHERE 1=1--FMemNo NOT IN(SELECT FMemNo FROM TMember)
group by FMemId,FName,FGender,FBirthdayType,FBirthday,FMobile
SELECT * FROM TImpMember WHERE FMemId = 0
SELECT FMemNo,SUM(1) FROM #Member
GROUP BY FMemNO
ORDER BY SUM(1) DESC
UPDATE TImpMember SET FMemNO =FCardNo
UPDATE TImpMember SET FCardnO = 'J' + FCardnO WHERE FCompId = 5509019528387075264
AND FCardnO IN(SELECT FMemNo FROM TMember)
UPDATE TImpMember SET FCardnO = 'M' + FCardnO WHERE FCompId = 5070579149810335139
AND FCardnO IN(SELECT FMemNo FROM TMember)
SELECT FMemNo,sum(1)
FROM TImpMember
GRoup by FMemNo
order by sum(1) desc
AND FMemId IN(SELECT FMemId FROM TMember)
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,
FCardState AS FState,
FCreateDate AS FCreateDate,
ISNULL(FExpiredDate,DATEADD(year,100, FCreateDate)) AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
FMemo AS FMemo
FROM TImpMember
WHERE FCardTypeId IS NOT NULL
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
WHERE FCardTypeId IS NOT NULL
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(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMember AS A
WHERE FCardTypeId IS NOT NULL
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,''
FROM TImpMember AS A
WHERE ISNULL(A.FBalance2 ,0)!= 0
AND FCardTypeId IS NOT NULL
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,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMember AS A
WHERE ISNULL(A.FBalance2 ,0)!= 0
AND FCardTypeId IS NOT NULL
SELECT * FROM TMemberCard WHERE FCardNO = 'q99909738'
SELECT * FROM TMemberCardAccount WHERE FCardId = 2277964
SELECT * FROM TImpMember WHERE FCardNo = 'q99909738'
UPDATE TImpMember SET FIsLoad = 0
ALTER TABLE TImpMember ADD FBalance2 FLOAT
UPDATE A SET A.FBalance2 = B.decMoneySurplus
FROM TImpMember AS A,TImpMemberAcct AS B
WHERE A.FCardId = B.FCardId
AND intAccountCate = 6
SELECT * FROM TImpTransLog
SELECT * FROM TMemberCardType
UPDATE TMemberCard SET FExpiredDate = DATEADD(YEAR,100,FCreateDate)
WHERE FTypeId IN(SELECT FId FROM TMemberCardType WHERE FNo <= '700')
AND FCardId IN(SELECT FCardId FROM TImpMember)
SELECT CardNo,SUM(1)
FROM TImpMemberCard
GROUP BY CardNo
ORDER BY SUM(1) DESC
delete TImpMemberCard
select dbo.FNNewId() AS FId, dbo.FNNewId() AS FCourseId, 'WD_' + vhrName AS FNo, vhrName AS FName
INTO TImpItem
from TImpMemberPack
GROUP BY vhrName
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking)
SELECT FId,FNo,FName,FName,FName,0,dbo.FNGetFirstPinYin(FName),'',1,1,1,'','','',1,0,0,0,0,0,0,0,0
FROM TImpItem
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FCourseId AS FId,
I.FNo + 'L1',
I.FName AS FName,
'' AS FBriefCode,
I.FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') 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
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
ALTER TABLE TImpMemberPack ADD FMemId BIGINT
ALTER TABLE TImpMemberPack ADD FCreateDate DATETIME
ALTER TABLE TImpMemberPack ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberPack ADD FItemId BIGINT
ALTER TABLE TImpMemberPack ADD FCourseId BIGINT
ALTER TABLE TImpMemberPack ADD FMemCourseId BIGINT
ALTER TABLE TImpMemberPack ADD FCompId BIGINT
UPDATE A
SET A.FCreateDate = dtmCreateTime,
A.FExpiredDate = dtmLimitDate
FROM TImpMemberPack AS A
UPDATE A
SET A.FMemCourseId = dbo.FNnewId()
FROM TImpMemberPack AS A
WHERE A.FMemCourseId IS NULL
UPDATE A
SET A.FMemId = B.FMemId,
A.FCompId = B.FCompId
FROM TImpMemberPack AS A ,TImpMember AS B
WHERE A.FCardId = B.Id
UPDATE A
SET A.FItemId = B.FItemId,
A.FCourseId = B.FId
FROM TCourse AS B,TImpMemberPack AS A
WHERE B.FName = A.vhrName
SELECT * FROM TImpError
SELECT * FROM TImpMemberAcct WHERE FCardId = 2299659
SELECT * FROM TImpMemberAcct WHERE intAccountCate = 6
SELECT * FROM TImpMemberPack WHERE intAccountCate = 6
UPDATE TImpMember SET FIsLoad = 0;
SELECT * FROM TImpMember
WHERE id not in(SELECT Id FROM TImpMemberCard)
SELECT * FROM TImpMemberCard
WHERE id not in(SELECT Id FROM TImpMember)
SELECT COUNT(1) FROM TImpMember
SELECT COUNT(1) FROM TImpMemberCard
select ID,SUM(1) FROM TImpMemberCard
GROUP BY ID
ORDER BY SUM(1) DESC
ALTER TABLE TImpMemberCard ADD FCardId BIGINT
UPDATE TImpMemberCard SET FCardId = dbo.FNNewId()
SELECT * FROM TImpError
SELECT * FROM TImpMemberPack
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FMemCourseId,FMemId,FCourseId,0,FItemId,FCompId,decTimeBalance,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,0
FROM TImpMemberPack AS A
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),FMemId,FCardId,0,FCourseId,FTime = getdate(),decTimeBalance,0,0,0,
FCompId,
'DR','Import',0,'',0
FROM TImpMemberPack
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT A.FId,A.FMemId,A.FTime,0,A.FCompId,'DR','Import',FBillNo,FContent,FAmount,FQuantity,FAmount,'',FEmployee,''
FROM TImpMemberAcctHist AS A
WHERE ISNULL(FMemId,0) != 0
AND <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != ''
WHERE A.FNo = hykh
delete TImpError
SELECT * FROM TImpMemberAcctHist
SELECT COUNT(1) FROM TImpMember
WHERE FCardId NOT IN(SELECT FCardId FROM TImpMemberAcctHist WITH(NOLOCK))
select *from TImpError
drop table TImpError
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>mdb<EFBFBD>ļ<EFBFBD>
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT dbo.FNNewId(),C.FMemId,A.dtmCreateTime,0,C.FCompId,'DR','Import',A. vhrBillCode,vhrItemName,isnull(b.decPrice,0),isnull(b.decAmount,0),isnull(b.decTotal,0),'',isnull(b.vhrEmployeeName,''),''
from [Sale_Bill] as a,[Sale_Billentry] as b,TImpMember AS C
where a.intId = b.intBillId
AND C.MemberId = A.intBuyerId
ALTER TABLE TImpMemberAcctHist ADD FCompId BIGINT
ALTER TABLE TImpMemberAcctHist ADD FShopId BIGINT
ALTER TABLE TImpMemberAcctHist ADD FMemId BIGINT
ALTER TABLE TImpMemberAcctHist ADD FId BIGINT
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMemberAcctHist AS A,TImpMEMBER AS B
WHERE A.FCardId = B.FCardId
UPDATE A
SET A.FShopId = B.ShopId
FROM TImpMember AS B,TImpMemberAcctHist AS A
WHERE A.vhrShopName = B.ShopName
UPDATE TImpMemberAcctHist SET FId = dbo.FNNewId()
UPDATE TImpMemberAcctHist SET FCompId = dbo.FNCompId('002') WHERE fShopId = 43623
UPDATE TImpMemberAcctHist SET FCompId = dbo.FNCompId('003') WHERE fShopId = 53863
INSERT INTO TMemberCardOldAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBizType,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
SELECT FId,FMemId,FCardId,3,ISNULL(dtmOPDateTime,'1753-01-01'),0,ISNULL(FCompId,0),vhrdatatype,vhrBillCode,cast(decinmoney as float),cast(decoutmoney as float),0,0,dtmOPDateTime,vhrdatatype
FROM TImpMemberAcctHist
SELECT * FROM TImpMemberAcctHist WHERE FCompiD IS NULL
INSERT TMemberPhoto(FMemId,FType,FImagePath)
SELECT FMemId,1,vhrMainImage + '.jpg',FMemNo
FROM TImpMember
WHERE vhrMainImage != ''
UPDATE TMemberPhoto SET FImagePath = REPLACE(FImagePath,'.jpg.jpg','.jpg')
SELECT * FROM TMemberPhoto
SELECT * FROM TImpMemberCard
SELECT FCardNo,FBalance,FArrear FROM TIMpMember WHERE FArrear != 0
AND FBalance + FArrear < 0
AND FArrear> 0
SELECT FBalance,FArrear FROM TImpMember WHERE FCardNo = '000852'
--Ƿ<EFBFBD><EFBFBD>
INSERT TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear)
SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'Account',A.FCardId,'DR_KK','DR_CardSale',0,'',0,3,ABS(FArrear) ,0,0,ABS(FArrear)
FROM TImpMember AS A
WHERE FArrear < 0
UPDATE A
SET A.FBalance = A.FBalance + B.FArrear,
A.FArrear = A.FArrear - B.FArrear
FROM TMemberCardAccount AS A,TImpMember AS B
WHERE A.FCardId = B.FCardId
AND A.FAcctId = 3
AND B.FArrear < 0
UPDATE A
SET A.FBalance = A.FBalance + B.FArrear,
A.FInAmount = A.FInAmount + B.FArrear,
A.FArrear = A.FArrear - B.FArrear
FROM TMemberCardAcctHist AS A,TImpMember AS B
WHERE A.FCardId = B.FCardId
AND A.FAcctId = 3
AND B.FArrear < 0
AND A.FBillType = 'DR'