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/卡迪堡/SQLQuery1.sql

624 lines
21 KiB

SELECT 'DELETE ' + name FROM sysobjects WHERE name like 'TMember%'
--Ãŵê
UPDATE TCompany SET FOldCompId = LEFT(FAddress,2)
sp_rename 'TCompany.FOldCompId','FOldId'
--씀SELECT * FROM TItem
UPDATE
TItem SET FNo = FNo + 'ÒÑɾ' ,FDeleted = 1
UPDATE
TItem SET FNoOfPad = FNo
SELECT * FROM TItem
SELECT *INTO TImpItem FROM s.WinMT_kdbsz005.dbo.MT_A04
SELECT *INTO TImpItemSub FROM s.WinMT_kdbsz005.dbo.MT_A04_1
SELECT * FROM TItem WHERE FNo = '5102'
SELECT * FROM TItemSub WHERE FItemId = 5100
SELECT * FROM TImpItemSub WHERE item_id = 5102
SELECT * FROM TImpItem
SELECT * FROM TImpItemSub
DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'ItemType')
DELETE TBasicType WHERE FKey = 'ItemType'
SELECT * FROM TBasicType WHERE FKey = 'ItemType'
INSERT TBasicType(FId,FNo,FName,FKey)
SELECT class_id,class_id,class_name, 'ItemType'
FROM TImpItem
GROUP BY class_id,class_name
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 auto_id,auto_id,auto_id,item_name,item_name,class_id,dbo.FNGetFirstPinYin(item_name),'',1,1,1,'','','',1,0,0,0,0,0,0,0,1
FROM TImpItem
INSERT TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointmode,FPOintValue,FDeptid,FAllowBooking,FEnabled)
SELECT max(auto_id),client_id,item_id,item_price,item_per,0,0,0,0,0,0,1
FROM TImpItemSub
WHERE client_id in(select FOldId FROM TCompany)
AND v_delete = 0
GROUP BY client_id,item_id,item_price,item_price
UPDATE A
SET A.FCompId = C.FId
FROM TItemSub AS A,TCompany AS C
WHERE A.FCompId = C.FOldId
UPDATE A
SET A.FVipPrice = b.item_per,
A.FPrice = b.item_price
FROM TItemSub AS A,TImpItemSub AS B,TCompany AS C
WHERE A.FItemId = B.item_id
AND A.FCompId = C.FId
AND C.FOldId = b.client_id
UPDATE TItem SET FNo = FNo
----²úÆ·
SELECT *INTO TImpGoods FROM s.WinMT_kdbsz005.dbo.MT_A06
SELECT *INTO TImpGoodsSub FROM s.WinMT_kdbsz005.dbo.MT_A06_1
DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'GoodsType')
DELETE TBasicType WHERE FKey = 'GoodsType'
SELECT * FROM TBasicType WHERE FKey = 'GoodsType'
INSERT TBasicType(FId,FNo,FName,FKey)
SELECT class_id,class_id,class_name, 'GoodsType'
FROM TImpGoods
GROUP BY class_id,class_name
DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'GoodsUnit')
DELETE TBasicType WHERE FKey = 'GoodsUnit'
INSERT TBasicType(FId,FNo,FName,FKey)
SELECT unit_id,unit_id,unit_name, 'GoodsUnit'
FROM TImpGoods
GROUP BY unit_id,unit_name
SELECT * FROM TImpGoodsSub
INSERT INTO TGoods(FId,FNo,FName,FNoOfPad,FTypeId,FBriefCode,FUnitId,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FValuationMode,FBarCode,FEnabled,FSpecification,FPurUnitId,FConsUnitId,FSupplierId,FStoreId,FConsStoreId,FSaleStoreId,FMaxStock,FMinStock,FPeriodEnabled,FShelfLife,FDctId,FPointMode,FPointValue,FDeptId,FUnitLock,FDescription,FCustom1,FCustom2,FCustom3)
SELECT auto_id,auto_id,project_name,auto_id,class_id,dbo.FNGetFirstPinYin(project_name),unit_id,0,0 AS FPurCostPrice,0 AS FSaleCostPrice,0 AS FConsCostPrice,0,'',1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'','','',''
FROM TImpGoods
UPDATE A
SET A.FSalePrice = b.project_price
FROM TGoods AS A,TImpGoodsSub AS B
WHERE A.FId = b.project_id
INSERT TGoodsSub(FId,FCompId,FGoodsId)
SELECT dbo.FNNewId(),C.FId,I.FId
FROM TGoods AS I,TCompany AS C
WHERE I.FId != 0
AND C.FId != 0
AND NOT EXISTS(SELECT TOP 1 1 FROM TGoodsSub AS B WHERE B.FCompId = C.FId AND B.FGoodsId = I.FId)
--Ô±¹¤
SELECT * INTO TImpEmployee FROM s.WinMT_kdbsz005.dbo.MT_A07
SELECT * FROM TImpEmployee
DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'Position')
DELETE TBasicType WHERE FKey = 'Position'
SELECT * FROM TBasicType WHERE FKey = 'Position'
INSERT TBasicType(FId,FNo,FName,FKey)
SELECT post_id,post_id,post_name, 'Position'
FROM TImpEmployee
GROUP BY post_id,post_name
SELECT * FROM TBasicType WHERE FKey LIKE 'Dep%'
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,FCardPW,FPW,FBank,FBankCardNo,FSSNo,FHCNo,FLinkMan,FLinkManTel,FLinkManAddr,FIntrId,FAllowSign,FAllowBooking,FContractType,FState,FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate,FDescription,FCustom1,FCustom2,FCustom3)
SELECT auto_id,auto_id,staff_name,'','',staff_name,5103542487188977994,post_id,0,dbo.FNGetFirstPinYin(staff_name),case when staff_sex = 'Å®' then 0 else 1 end,0,0,'','','','',
'','',staff_tel,'','',staff_identy,'G',staff_birthday,'','','','','','','','','','',0,0,1,0,1,0,v_insert,v_insert,null,null,'','','',''
FROM TImpEmployee WHERE v_delete = 0
AND client_id IN(SELECT FOldId FROM TCompany)
INSERT TEmployeeSub(FCompId,FEmpId,FSerialNo)
SELECT C.FId,A.auto_id,a.auto_id
FROM TImpEmployee AS A,TCompany AS C
WHERE C.FOldId = A.client_id
SELECT * FROM TEmployee WHERE FMobilePHone != ''
--¿¨Àà±ð
SELECT *INTO TImpCardType FROM s.WinMT_kdbsz005.dbo.MT_A05
SELECT *INTO TImpCardTypeSub FROM s.WinMT_kdbsz005.dbo.MT_A05_1
SELECT * FROM TImpCardType
INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
SELECT auto_id,auto_id,card_type,1,2,0,3,0,0,0,0,0,0,0,0,100,1,1,1,1,1,0,0,0,0
FROM TImpCardType
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 NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
--µ¼»áÔ±
SELECT auto_id,card_img INTO TImpPhoto FROM s.WinMT_kdbsz005.dbo.MT_C01
WHERE card_img is not null
SELECT * INTO TImpMember FROM s.WinMT_kdbsz005.dbo.MT_C01
SELECT auto_id,card_code,card_name,card_pwd,card_tel,card_sex FROM s.WinMT_kdbsz005.dbo.MT_C01
SELECT auto_id,card_no,card_name,card_pwd,card_tel,card_sex,card_birthday_month,card_birthday_day,card_birthday_sign,card_star,card_grade,card_source,msg_state,card_remark,custome_type,client_id,dep_name,staff_id,staff_name,total_num,last_date,last_client_id,last_dep_name,first_sign,card_state,card_source_type,arrears_gold,repayment_gold,v_insert,v_update,v_login,v_client_no,v_delete,nick_name,age_section,occupat_name,express_addr,surplus_coin,consum_coin,introducer_id,introducer_id_id,edit_sign
INTO TImpMember
FROM s.WinMT_kdbsz005.dbo.MT_C01
WHERE v_delete = 0
SELECT auto_id,card_code,client_id,dep_name,staff_id,staff_name,class_id,class_name,card_typeid,card_type,surplus_gold,consum_gold,surplus_integral,consum_integral,consum_before_gold,last_date,last_client_id,last_dep_name,last_staff_id,last_staff_name,effective_date,acc_state,settle_before_gold,acc_remark,surplus_gold_old,surplus_gold_date,v_insert,v_update,v_login,v_client_no,v_delete,surplus_gold_bak
INTO TImpCard
FROM s.WinMT_kdbsz005.dbo.MT_C02
WHERE v_delete = 0
SELECT auto_id,card_code,client_id,dep_name,staff_id,staff_name,class_id,class_name,card_typeid,card_type,surplus_num,consum_num,surplus_freenum,consum_freenum,consum_before_num,consum_before_freenum,last_date,last_client_id,last_dep_name,last_staff_id,last_staff_name,effective_date,acc_state,settle_before_num,acc_remark,surplus_num_money,consum_num_money,surplus_num_old,surplus_num_date,v_insert,v_update,v_login,v_client_no,v_delete
INTO TImpCourse
FROM s.WinMT_kdbsz005.dbo.MT_C03
WHERE v_delete = 0
SELECT * FROM TImpCourse
SELECT * FROM TImpMember
--»áÔ±
ALTER TABLE TImpMember ADD FDeleted BIT
ALTER TABLE TImpMember ADD FState INT
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember ADD FName VARCHAR(50)
ALTER TABLE TImpMember ADD FMobilePhone VARCHAR(50)
ALTER TABLE TImpMember ADD FBirthday DATETIME
ALTER TABLE TImpMember ADD FBirthdayType CHAR
ALTER TABLE TImpMember ADD FCompId BIGINT
ALTER TABLE TImpMember ADD FGender INT
ALTER TABLE TImpMember ADD FMemo VARCHAR(2222)
ALTER TABLE TImpMember ADD FPW VARCHAR(2222)
ALTER TABLE TImpMember ADD FCreateDate DATETIME
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
UPDATE TImpMember SET FState = 1
--»áÔ±ID
UPDATE TImpMember SET FMemId = auto_id WHERE FMemId IS NULL
--»áÔ±Ö÷¿¨ºÅ
UPDATE TImpMember SET FMemNo = card_no
--ÐÕÃû
UPDATE TImpMember SET FName = card_name
--ÊÖ»ú
UPDATE TImpMember SET FMobilePhone = card_tel
--ÐÔ±ð
UPDATE TImpMember SET FGender = CASE WHEN Card_sex = 'ÄÐ' THEN 1 ELSE 0 END
--ÃÜÂë
UPDATE TImpMember SET FPW = card_pwd
--¿ª»§Ê±¼ä
UPDATE TImpMember SET FCreateDate = v_insert
--״̬
UPDATE TImpMember SET FState = 4 WHERE card_state='²»¿ÉÓÃ'
--±¸×¢
UPDATE TImpMember SET FMemo = card_remark
--Ãŵê
UPDATE TImpMember SET FCompId = null
UPDATE A
SET A.FCompId = B.FCompId
FROM TImpMember AS A,TImpCard AS B
WHERE A.auto_id = B.card_code
and A.FCompId IS NULL
UPDATE A
SET A.FCompId = B.FCompId
FROM TImpMember AS A,TImpCourse AS B
WHERE A.auto_id = B.card_code
and A.FCompId IS NULL
UPDATE TImpCard SET FCompId = 1 WHERE FCompId IS NULL
UPDATE TImpCourse SET FCompId = 1 WHERE FCompId IS NULL
SELECT * FROM TImpMember WHERE FCompId IS NULL
SELECT * FROM TImpCard WHERE FCompId IS NULL
SELECT * FROM TImpCourse WHERE FCompId IS NULL
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 FBriefCode,
0 AS FTypeId,
FCompId AS FCompId,
FCreateDate AS FCreateDate,
FGender AS FGender,
ISNULL(FBirthdayType,'G') AS FBirthdayType,
FBirthday AS FBirthday,
'' AS FTelephone,
FMobilePhone AS FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
FPW AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
FMemo AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
WHERE v_delete = 0
AND (auto_id in(select card_code from TImpCard)
OR auto_id in(select card_code from TImpCourse))
--´¢Öµ¿¨
SELECT * FROM TImpMember WHERE FMemid = 100587
SELECT * FROM TImpCourse WHERE card_code = 79913
SELECT * FROM TImpCard WHERE acc_state != 0
ALTER TABLE TImpCard ADD FDeleted BIT
ALTER TABLE TImpCard ADD FState INT
ALTER TABLE TImpCard ADD FMemId BIGINT
ALTER TABLE TImpCard ADD FCardId BIGINT
ALTER TABLE TImpCard ADD FTypeId BIGINT
ALTER TABLE TImpCard ADD FCompId BIGINT
ALTER TABLE TImpCard ADD FMemo VARCHAR(2222)
ALTER TABLE TImpCard ADD FCardNo VARCHAR(33)
ALTER TABLE TImpCard ADD FCreateDate DATETIME
ALTER TABLE TImpCard ADD FExpiredDate DATETIME
ALTER TABLE TImpCard ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpCard ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpCard ADD FBizEmpId BIGINT
ALTER TABLE TImpCard ADD FIndex INT DEFAULT 0
UPDATE A
SET A.FIndex = (SELECT COUNT(1)+1 FROM TImpCard AS B WHERE B.card_code = A.card_code AND A.v_insert > B.v_insert )
FROM TImpCard AS A
SELECT * FROM TImpCard WHERE FIndex = 0
ORDER BY card_code,FIndex
SELECT * FROM TImpCard WHERE FCardNO = '41110'
SELECT * FROM TImpMember WHERE auto_id = '106680'
UPDATE TImpCard SET FCardNo = FCardNo + '.' + CAST(Findex AS VARCHAR) WHERE FIndex > 1
--¿¨Àà±ð
UPDATE TImpCard SET FTypeId = card_typeid
--¿¨ID
UPDATE TImpCard SET FCardId = auto_id
--»áÔ±ID
UPDATE TImpCard SET FMemId = card_code
--¿¨ºÅ
UPDATE A SET A.FCardNo = B.FMemNo
FROM TImpCard AS A,TImpMember AS B
WHERE A.card_code = B.auto_id
--Óà¶î
UPDATE TImpCard SET FBalance = surplus_gold
--½¨Á¢ÈÕÆÚ
UPDATE TImpCard SET FCreateDate = v_insert
UPDATE TImpCard SET FExpiredDate = effective_date
--Ãŵê
UPDATE TImpCard SET FCompId = (SELECT FId FROM TCompany AS C WHERE C.FOldId = client_id)
UPDATE TImpCard SET FCompId = 1 WHERE FCompId IS NULL
SELECT * FROM TImpCard WHERE FCompId IS NULL
--±¸×¢
UPDATE TImpCard SET FMemo = ISNULL(acc_remark,'')
--״̬
UPDATE TImpCard SET FState = 4 WHERE acc_state = 1
UPDATE TImpCard SET FState = 1
--Ô±¹¤
UPDATE TImpCard SET FBizEmpId = staff_id
--µ¼Èë
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo,
FBizEmpId
)
SELECT
FCardId AS FCardId,
FCardNo AS FCardNo,
FCardNo AS FFaceNo,
FTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
FState AS FState,
FCreateDate AS FCreateDate,
FExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(FMemo,''),
FBizEmpId
FROM TImpCard
WHERE ISNULL(FTypeId,0) != 0
AND v_delete = 0
AND card_code != ''
-- AND FDeleted = 0
INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT dbo.FNNewId(),FMemId,FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL,''
FROM TImpCard
WHERE v_delete = 0
AND card_code != ''
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.FTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),''
FROM TImpCard AS A
WHERE 1=1
AND v_delete = 0
AND card_code != ''
AND FBalance != 0
--ÁƳÌ
--ÁƳ̺ʹ¢Öµ¿¨
ALTER TABLE TImpCourse ADD FId BIGINT
ALTER TABLE TImpCourse ADD FDeleted BIT
ALTER TABLE TImpCourse ADD FState INT
ALTER TABLE TImpCourse ADD FMemId BIGINT
ALTER TABLE TImpCourse ADD FCompId BIGINT
ALTER TABLE TImpCourse ADD FItemId BIGINT
ALTER TABLE TImpCourse ADD FBizEmpId BIGINT
ALTER TABLE TImpCourse ADD FCourseId BIGINT
ALTER TABLE TImpCourse ADD FMemo VARCHAR(2222)
ALTER TABLE TImpCourse ADD FCreateDate DATETIME
ALTER TABLE TImpCourse ADD FExpiredDate DATETIME
ALTER TABLE TImpCourse ADD FPurTimes DECIMAL(18,6)
ALTER TABLE TImpCourse ADD FUsedPurTimes DECIMAL(18,6)
ALTER TABLE TImpCourse ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpCourse ADD FRemainPurTimes DECIMAL(18,6)
SELECT * FROM TImpCourse
--»áÔ±ID
UPDATE TImpCourse SET FId = auto_id
UPDATE TImpCourse SET FMemId = card_code
--ÏîÄ¿ID
UPDATE TImpCourse SET FItemId = card_typeId
--Ãŵê
UPDATE TImpCourse SET FCompId = (SELECT FId FROM TCompany AS C WHERE C.FOldId = client_id)
SELECT * FROM TImpCourse WHERE FCompId IS NULL
UPDATE TImpCourse SET FCompiD = 1 WHERE FCOmpiD IS NULL
--ÏîÄ¿ID
UPDATE TImpCourse SET FBizEmpId = staff_id
--Ê£Óà´ÎÊý
UPDATE TImpCourse SET FRemainPurTimes = surplus_num
--±¸×¢
UPDATE TImpCourse SET FMemo = isnull(acc_remark,'')
--½¨Á¢ÈÕÆÚ
UPDATE TImpCourse SET FCreateDate = v_insert
UPDATE TImpCourse SET FExpiredDate = effective_date
--״̬
UPDATE TImpCourse SET FState = 4 WHERE acc_state = 1
UPDATE TImpCourse SET FState = 1
SELECT * FROM TImpCourse WHERE acc_state != 0
select card_typeid,card_type
FROM TImpCourse
group by card_typeid,card_type
order by card_typeid
SELECT * FROM TBasicType WHERE FKey = 'CourseType'
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,
I.FNo + 'L1' AS FNo,
I.FName AS FName,
'' AS FBriefCode,
FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
5084986468097883890 AS FTypeId,
0 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,
I.FPrice AS FPrice,
I.FPrice AS FAmount,
1 AS FCalcMode
FROM TItem AS I
WHERE FDeleted = 0
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FUsedPurTimes,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FId,FMemId,FItemId,0,FItemId,FCompId,FRemainPurTimes,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,ISNULL(FMemo,''),1,0
FROM TImpCourse
WHERE 1=1
AND v_delete = 0
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),FMemId,FId,0,FItemId,FTime = getdate(),FRemainPurTimes,0,0,0,
FCompId,
'DR','Import',0,'',0
FROM TImpCourse
WHERE 1=1
AND v_delete = 0
SELECT * FROM TMemberCourseLog
SELECT * FROM TUser
SELECT * FROM TMember WHERE FMemId = 61245
UPDATE TMemberCourse
SELECT * FROM TMemberCourse WHERE FCalcMode = 2
--½»Ò×ÀúÊ·
ALTER TABLE TimpCardLog ADD FId BIGINT
UPDATE TImpCardLog SET FId = dbo.FNNewId()
ALTER TABLE TimpCourseLog ADD FId BIGINT
UPDATE TimpCourseLog SET FId = dbo.FNNewId()
INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
SELECT FId,ISNULL((SELECT FId FROM TCompany AS C WHERE C.FOldId = cast(A.Client_id as decimal)),1),card_code,v_insert,acc_code,'',serve_type,doc_no,isnull(item_name,serve_type),0,1,payment_gold, isnull(pay_type,'') + cast(cast(payment_gold as float) as varchar(1100)) ,isnull(staff_name,''),''
FROM TImpCardLog AS A
INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
SELECT FId,ISNULL((SELECT FId FROM TCompany AS C WHERE C.FOldId = cast(A.Client_id as decimal)),1),card_code,v_insert,acc_code,'',serve_type,doc_no,isnull(item_name,serve_type),0,1,payment_gold, isnull(pay_type,'') + cast(cast(payment_gold as float) as varchar(1100)) ,isnull(staff_name,''),''
FROM TImpCourseLog AS A
SELECT * FROM TImpCardLog WHERE item_name is null
select * from TImpCardLog
select C12.auto_id,C12.client_id , C12.card_code,C12.acc_code,C12.serve_type, C12.v_insert, C12.payment_gold, C12.free_gold, C12.total_integral, C12.serve_name, D02.staff_name, C12.doc_no, D02.item_name, A08.pay_type, C12.v_login
INTO TImpCardLog
from s.WinMT_kdbsz005.dbo.MT_C12 C12 left join s.WinMT_kdbsz005.dbo.MT_A08 A08 on C12.pay_id=A08.auto_id left join s.WinMT_kdbsz005.dbo.MT_D02 D02 on C12.doc_no=D02.open_no and C12.v_client_no=D02.v_client_no and D02.first_sign='0' and D02.v_delete='0'
where C12.v_delete='0'
--and C12.serve_type='³äÖµ' and C12.acc_code='61815'
order by C12.v_insert
DROP TABLE TImpCourseLog
select client_id,C13.auto_id,C13.acc_code,C13.card_code,C13.serve_type, C13.v_insert as v_insert, C13.free_gold, C13.free_num, C13.payment_gold, C13.serve_name, D02.staff_name, C13.doc_no, D02.item_name, A08.pay_type, C13.v_login
INTO TImpCourseLog
from s.WinMT_kdbsz005.dbo.MT_C13 C13 left join s.WinMT_kdbsz005.dbo.MT_A08 A08 on C13.pay_id=A08.auto_id
left join s.WinMT_kdbsz005.dbo.MT_D02 D02 on C13.open_list=D02.open_list and C13.v_client_no=D02.v_client_no and D02.first_sign='0' and D02.v_delete='0'
where C13.v_delete='0'
order by C13.v_insert
SELECT * FROM TImpCourseLog
SELECT * FROM s.WinMT_kdbsz005.dbo.MT_C03
WHERE auto_id =7152
select count(1) from TMemberPhoto