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/坤丽/SQLQuery9.sql

447 lines
14 KiB

SELECT * FROM TIMpMember1
SELECT * FROM TIMpMember2
SELECT * FROM TImpMember2
SELECT FName,SUM(1) FROM TMemberCardType
GROUP BY FName
ORDER BY SUM(1)
SELECT * FROM Member_CardType
SELECT * FROM Member_CardInfo WHERE vhrCardNo = '000001'
SELECT * FROM Member_Account WHERE vhrMemberCardNo = '000001'
SELECT * FROM Member_Info WHERE intId = 2442
SELECT * FROM Member_AccountDetail WHERE vhrMemberCardNo = '000001'
ALTER TABLE TImpMember2 ADD FMemId BIGINT
ALTER TABLE TImpMember2 ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMember2 ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember2 ADD FName VARCHAR(50)
ALTER TABLE TImpMember2 ADD FGender INT
ALTER TABLE TImpMember2 ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember2 ADD FTelephone VARCHAR(50)
ALTER TABLE TImpMember2 ADD FCardTypeId BIGINT
ALTER TABLE TImpMember2 ADD FCourseId BIGINT
ALTER TABLE TImpMember2 ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMember2 ADD FRemainTimes INT
ALTER TABLE TImpMember2 ADD FPurTimes INT
ALTER TABLE TImpMember2 ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMember2 ADD FItemId BIGINT
ALTER TABLE TImpMember2 ADD FCreateDate DATETIME
ALTER TABLE TImpMember2 ADD FExpiredDate DATETIME
ALTER TABLE TImpMember2 ADD FCompId BIGINT
ALTER TABLE TImpMember2 ADD FCardId BIGINT
ALTER TABLE TImpMember2 ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMember2 ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMember2 ADD FPoint DECIMAL(18,6)
ALTER TABLE TImpMember2 ADD FBirthday DATETIME
ALTER TABLE TImpMember2 ADD FBirthdayType CHAR
ALTER TABLE TImpMember2 ADD FState INT
ALTER TABLE TImpMember2 ADD FDeleted BIT DEFAULT 0 NOT NULL
UPDATE TImpMember2 SET FMemNo =
UPDATE TImpMember2 SET FCardNO = FMemNo
UPDATE TImpMember2 SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL
UPDATE TImpMember2 SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMember2 SET FName =
UPDATE TImpMember2 SET FGender = CASE WHEN ='' THEN 1 ELSE '0' END
UPDATE TImpMember2 SET FBalance =
UPDATE TImpMember2 SET FState = 4,FMemo = FMemo + '老系统中显示已换卡' WHERE ISNULL(,'') = '换卡'
UPDATE TImpMember2 SET FState = 5 WHERE ISNULL(,'') = '挂失'
UPDATE TImpMember2 SET FPoint =
UPDATE A
SET A.FMobile = ISNULL(B.vhrMobilePhone,B.vhrTel)
FROM TImpMember2 AS A,Member_Info AS B,Member_CardInfo AS C
WHERE A.FMemNo = C.vhrCardNo
AND B.intId = C.intMemberId
UPDATE A
SET A.FTelephone = ISNULL(B.vhrTel,'')
FROM TImpMember2 AS A,Member_Info AS B,Member_CardInfo AS C
WHERE A.FMemNo = C.vhrCardNo
AND B.intId = C.intMemberId
AND ISNULL(A.FMobile,'') = ''
UPDATE A
SET A.FCreateDate = B.dtmCreateTime,
A.FMemo = ISNULL(B.txtRemark,''),
A.FExpiredDate = ISNULL(b.dtmLiftTerminateTime,'9999-01-01')
FROM TImpMember2 AS A,Member_CardInfo AS B
WHERE A.FCardNO = B.vhrCardNo
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMember2 AS A,TMemberCardType AS B
WHERE A. = B.FName
SELECT * FROM TIMpMember2
WHERE FCardNO IN(SELECT FROM TIMpMember)
Lift Terminate
ALTER TABLE TImpMember3 ADD FMemiD BIGINT
ALTER TABLE TImpMember1 ADD FMemiD BIGINT
UPDATE A
SET A.FMemId = B.FMemid
FROM TImpMember1 AS A,TImpMember AS B
WHERE A. = B.
UPDATE A
SET A.FMemId = B.FMemid
FROM TImpMember3 AS A,TImpMember AS B
WHERE A. = B.
UPDATE A
SET A. = B.,
A.FMemNo = B.,
A.FCardNO = b.
FROM TImpMember AS A,TImpMember3 AS B
WHERE A.FMemId = B.FMemId
UPDATE A
SET A. = B.,
A.FMemNo = B.,
A.FCardNO = b.
FROM TImpMember AS A,TImpMember1 AS B
WHERE A.FMemId = B.FMemId
UPDATE TImpMember3 SET = REPLACE(,'_3','')
UPDATE TImpMember1 SET = REPLACE(,'_1','')
UPDATE TImpMember SET = REPLACE(,'_1','')
UPDATE TImpMember SET = REPLACE(,'_3','')
UPDATE TImpMember3 SET = + '_3' WHERE IN(SELECT FMemNo FROM TImpMember2)
UPDATE TImpMember1 SET = + '_1' WHERE IN(SELECT FMemNo FROM TImpMember2)
UPDATE TImpMember2 SET FMemNo = FMemNo + '_2' WHERE IN(SELECT FROM TImpMember )
UPDATE TImpMember2 SET FCardNo = FMemNo
SELECT * FROM TImpMember2 WHERE FName IS NULL
DELETE TImpMember2 WHERE FName IS NULL
select * from TImpMember3
UPDATE A
SET A.FMemNo = B.FMemNo
FROM TMember AS A,TImpMember AS B
WHERE A.FMemId = B.FMemId
UPDATE A
SET A.FCardNO = B.FCardNO
FROM TMemberCard AS A,TImpMember AS B
WHERE A.FCardId = B.FCardId
--开始
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,
1 AS FCompId,
ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate,
FGender AS FGender,
'G' AS FBirthdayType,
FBirthday AS FBirthday,
ISNULL(FTelephone,'') 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,
ISNULL( 0,0) AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
ISNULL('','') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember2
--导卡
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,
1 AS FCompId,
FMemId AS FMemId,
ISNULL(FState ,1)AS FState,
ISNULL(FCreateDate,1900) AS FCreateDate,
ISNULL(FExpiredDate,'9999-01-01'),
0 AS FTotalTimes,
0 AS FUsedTimes,
1 AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(FMemo,'') AS FMemo
FROM TImpMember2
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,ISNULL(FBalance,0),ISNULL(FBalance,0),0,FCreateDate,DATEADD(year,100, FCreateDate) AS FExpiredDate,''
FROM TImpMember2 AS A
WHERE FBalance IS 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,1,'DR','Import',0,'',ISNULL(A.FBalance,0),0,ISNULL(A.FBalance,0),0,getdate(),''
FROM TImpMember2 AS A
SELECT * FROM TMember
--End OF 2
--------------------------------------------------------------------------
DROP TABLE TIMpMember1
DROP TABLE TIMpMember3
DROP TABLE TImpMember
SELECT * INTO TImpMember FROM TImpMember1 WHERE 1=0
--
UPDATE TIMpMember1 SET = + '1' WHERE = '储值卡'
UPDATE TIMpMember3 SET = + '1' WHERE = '储值卡'
SELECT INTO #Member1 FROM TIMpMember1 WHERE IN(SELECT FROM TIMpMember3)
SELECT INTO #Member3 FROM TIMpMember3 WHERE IN(SELECT FROM TIMpMember1)
UPDATE TIMpMember1 SET = + '_1' WHERE IN(SELECT FROM #Member1)
UPDATE TIMpMember3 SET = + '_3' WHERE IN(SELECT FROM #Member1)
INSERT TImpMember
SELECT * FROM TIMpMember1
INSERT TImpMember
SELECT * FROM TIMpMember3
SELECT * FROM TImpMember1 WHERE = '900539'
SELECT * FROM TImpMember3 WHERE = '900539'
UPDATE TImpMember SET = + '_1'
SELECT FMemNo ,SUM(1)
FROM TImpMember
GROUP BY FMemNo
HAVING(SUM(1) > 1)
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember ADD FName VARCHAR(50)
ALTER TABLE TImpMember ADD FGender 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 FBirthday DATETIME
ALTER TABLE TImpMember ADD FBirthdayType CHAR
ALTER TABLE TImpMember ADD FDeleted BIT DEFAULT 0 NOT NULL
SELECT * FROM TImpMember
UPDATE TImpMember SET FCompID = 1
UPDATE TImpMember SET FMemNo =
UPDATE TImpMember SET FCardNO = FMemNo
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL
UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMember SET FName =
UPDATE TImpMember SET FGender = CASE WHEN ='' THEN 1 ELSE '0' END
UPDATE TImpMember SET FBalance =
--UPDATE TImpMember SET FDeleted = 1 WHERE ISNULL(状态,'') = '换卡'
UPDATE TImpMember SET FPoint =
UPDATE TImpMember SET FBirthdayType = 'G'
UPDATE TImpMember SET FBirthday = NULL
UPDATE TImpMember SET FMobile =
UPDATE TImpMember SET FCreateDate =
UPDATE TImpMember SET FExpiredDate =
UPDATE TImpMember SET FMemo =
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMember AS A,TMemberCardType AS B
WHERE A. = B.FName
SELECT * FROM TIMpMember WHERe != 1
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,
1 AS FCompId,
ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate,
FGender AS FGender,
'G' 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,
ISNULL( 0,0) AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
ISNULL('','') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
--导卡
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,
1 AS FCompId,
FMemId AS FMemId,
1 AS FState,
ISNULL(FCreateDate,1900) AS FCreateDate,
ISNULL(FExpiredDate,'9999-01-01'),
0 AS FTotalTimes,
0 AS FUsedTimes,
1 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,DATEADD(year,100, FCreateDate) 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,1,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),''
FROM TImpMember AS A
---------------------------------------------------------------------------
SELECT FROM TImpMember2
GROUP BY
SELECT FROM TImpMember1
GROUP BY
SELECT FROM TImpMember3
GROUP BY
INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
SELECT dbo.FNNewId(),'20-' + ,,1,2,0,3,0,0,0,0,0,0,0,0,0,0,'9999-12-31','',1,0,0,0,0,0
FROM TImpMember2
GROUP BY
INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
SELECT dbo.FNNewId(),'10-' + ,,1,2,0,3,0,0,0,0,0,0,0,0,0,0,'9999-12-31','',1,0,0,0,0,0
FROM TImpMember1
GROUP BY
INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
SELECT dbo.FNNewId(),'30-' + ,,1,2,0,3,0,0,0,0,0,0,0,0,0,0,'9999-12-31','',1,0,0,0,0,0
FROM TImpMember3
GROUP BY