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

134 lines
5.2 KiB

1 year ago
use qingdao_oufan
SELECT * FROM TImpCourse
drop table TImpCourse
ALTER TABLE TImpCourse ADD FItemId BIGINT
ALTER TABLE TImpCourse ADD FId BIGINT
UPDATE TImpCourse SET FItemId = dbo.FNNewId()
UPDATE TImpCourse SET FId = dbo.FNNewId()
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)
SELECT FItemId,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0,FBriefCode = dbo.FNGetFirstPinYin(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>),
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
FROM TImpCourse
SELECT * FROM TImpCourse
WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> IN(
DELETE A
FROM TImpCourse AS A,(
SELECT <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,MIN(FItemId)AS FItemId
FROM TImpCourse
GROUP BY <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
HAVING(SUM(1) > 1)
)AS B
WHERE A. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AND A.FItemId != B.FItemId
DELETE TImpCourse WHERE
--<EFBFBD>Ƴ<EFBFBD>
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FId AS FId,
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> + 'L1' AS FNo,
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '-' + '<EFBFBD>Ƴ<EFBFBD>1' AS FName,
'' AS FBriefCode,
FItemId AS FItemId,
0 AS FPackId,
1 AS FSequence,
0 AS FTypeId,
CAST( <EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD> AS FLOAT) 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,
CASE WHEN CAST(<EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD> AS FLOAT) > 0 THEN CAST(<EFBFBD><EFBFBD><EFBFBD>ۼ۸<EFBFBD> AS FLOAT) / CAST( <EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD> AS FLOAT) ELSE 0 END AS FPrice,
CAST(<EFBFBD><EFBFBD><EFBFBD>ۼ۸<EFBFBD> AS FLOAT) AS FAmount,
1 AS FCalcMode
FROM TImpCourse AS I
INSERT TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled)
SELECT dbo.FNNewId(),C.FId,I.FId,I.FPrice,I.FVipPrice,I.FTime,I.FDctId,I.FPointMode,I.FPointValue,I.FDeptId,I.FAllowBooking,I.FEnabled
FROM TItem AS I,TCompany AS C
WHERE I.FId != 0
AND C.FId != 0
AND NOT EXISTS(SELECT TOP 1 1 FROM TItemSub AS B WHERE B.FCompId = C.FId AND B.FItemId = I.FId)
--Ա<EFBFBD><EFBFBD>
SELECT * FROM TImpEmployee WHERE FPosId IS NULl
ALTER TABLE TImpEmployee ADD FDeptId BIGINT
ALTER TABLE TImpEmployee ADD FPosId BIGINT
UPDATE A
SET A.FPosId = B.FId
FROM TImpEmployee AS A,TBasicType AS B
WHERE ( B.FName LIKE '%' + A.ְλ + '%' OR A.ְλ LIKE '%' + B.FName + '%')
AND B.FKey = 'Position'
UPDATE A
SET A.FPosId = B.FId
FROM TImpEmployee AS A,TBasicType AS B
WHERE A.ְλ = 'ϴ<EFBFBD><EFBFBD>ʦ'
AND B.FKey = 'Position'
AND B.FName = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE A
SET A.FDeptId = B.FId
FROM TImpEmployee AS A,TBasicType AS B
WHERE ( B.FName LIKE '%' + A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '%' OR A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%' + B.FName + '%')
AND B.FKey = 'department'
INSERT INTO TEmployee(FId,FNo,FName,FEnLname,FEnFname,FNickname,FDeptId,FPosId,FTechTypeId,FBriefCode,FGender,FStature,FWeight,FNationPlace,FNation,FEducation,FMarital,FAddress,FTelephone,FMobilePhone,FQQ,FEmail,FIdCard,FBirthdayType,FBirthday,FCardNo,FPW,FBank,FBankCardNo,FSSNo,FHCNo,FLinkMan,FLinkManTel,FLinkManAddr,FIsManager,FAllowBooking,FContractType,FState,FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate, FPrice,FTags)
SELECT dbo.FNNewId(),<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,FEnLname = '',FEnFname = '',FNickname = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,FDeptId = 0,
FPosId,FTechTypeId = 0,FBriefCode = DBO.FNGetFirstPinYin(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>),FGender = 0,
FStature = 0,FWeight = 0,FNationPlace = 0,FNation = 0,FEducation = '',FMarital = '',FAddress = '',
FTelephone = '',FMobilePhone = '',FQQ = '',FEmail = '',FIdCard = '',FBirthdayType = 'L',FBirthday = NULL,
FCardNo = '', FPW ='',FBank = '',FBankCardNo = '',FSSNo = '',FHCNo ='',FLinkMan = '',
FLinkManTel = '',FLinkManAddr = '', FIsManager = 0,FAllowBooking = 1,FContractType = '',
FState = 1,FCreatorId = 0,FCreateDate = GETDATE(),FEntryDate = null,FExpiredDate = null,FLeaveDate = null,
FPrice = 0,FTags = ''
FROM TImpEmployee
ORDER BY <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpEmployee SET <EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<EFBFBD><EFBFBD><EFBFBD><EFBFBD> where <EFBFBD><EFBFBD><EFBFBD><EFBFBD>= ''
UPDATE TImpEmployee SET <EFBFBD><EFBFBD><EFBFBD><EFBFBD>='307_2' where <EFBFBD><EFBFBD><EFBFBD><EFBFBD>= 'С<EFBFBD><EFBFBD>'
SELECT * FROM TImpCardType
INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2,
FAcctId3,FDeposit3,FTimes,FAlertBalance,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,
FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FEnabled,FOrder,FDeptId,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
SELECT dbo.FNNewId() AS FId,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FNo,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FName,1 AS ValueType,1 AS FMaterial,0 AS FPrice,0 AS FCardFeeAmt,0 AS FAcctId,0 AS FDeposit,0 AS FAcctId2,0 AS FDeposit2,0 AS FAcctId3,0 AS FDeposit3,0 AS FTimes,0 AS FAlertBalance,0 AS FPaySmsFee,0 AS FTimeCard,0 AS FValidityPeriod,0 AS FValidityPeriodUnit,'' AS FExpiredDate,'' AS FDefaultMemo,'' AS FCreateTime,0 AS FAllowSale,0 AS FAllowRchg,1 AS FEnabled,0 AS FOrder,0 AS FDeptId,1,0,1,0
FROM TImpCardType