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

842 lines
24 KiB

use qingdao_chongshang_ok
use JiNan_FaBa_ZhongGongDian
SELECT * FROM hyxx WHERE hykh = '00252'
SELECT klxmc+kmc FROM hyxx WHERE cs > 0
GROUP BY klxmc+kmc
SELECT count(1) FROM hyxx WITH(NOLOCK)
ALTER TABLE hyxx ADD FCourseId BIGINT
ALTER TABLE hyxx ADD FItemId BIGINT
ALTER TABLE hyxx ADD FMemId BIGINT
ALTER TABLE hyxx ADD FMemNo VARCHAR(50)
ALTER TABLE hyxx ADD FCardTypeId BIGINT
ALTER TABLE hyxx ADD FName VARCHAR(50)
ALTER TABLE hyxx ADD FMobilePhone VARCHAR(50)
ALTER TABLE hyxx ADD FMemo VARCHAR(1000)
ALTER TABLE hyxx ALTER COLUMN FMemo VARCHAR(8000)
ALTER TABLE hyxx ADD FBirthday DATETIME
ALTER TABLE hyxx ADD FCreateDate DATETIME
ALTER TABLE hyxx ADD FIsCourse BIT
ALTER TABLE hyxx ADD FCompId BIGINT
ALTER TABLE hyxx ADD FBirhtday DATETIME
ALTER TABLE hyxx ADD FPW VARCHAR(50)
ALTER TABLE hyxx ADD FGender INT
ALTER TABLE hyxx ADD FBriefCode VARCHAR(50)
ALTER TABLE hyxx ADD FExpiredDate VARCHAR(100)
ALTER TABLE hyxx ADD FPoint DECIMAL(18,6)
ALTER TABLE hyxx ADD FBalance DECIMAL(18,6)
ALTER TABLE hyxx ADD FRemainTimes DECIMAL(18,6)
ALTER TABLE hyxx ADD FCardId BIGINT
ALTER TABLE hyxx ADD FCardState INT
ALTER TABLE hyxx ADD FCalcMode INT
ALTER TABLE hyxx ADD FValueType INT
alter table hyxx add kmc2 nvarchar(50)
alter table hyxx add yhzl nvarchar(50)
alter table hyxx add zkl nvarchar(50)
alter table hyxx ADD FCardTypeName NVARCHAR(100)
SELECT * FROM zkk
UPDATE A
SET A.kmc2 = b.kmc,
A.yhzl = b.yhzl
FROM hyxx AS A,hyczk AS C,czk AS B
WHERE A.hykh = C.hykh
AND C.Kid = b.id
UPDATE A
SET A.kmc2 = b.kmc,
A.zkl = b.zkl
FROM hyxx AS A,hyzkk AS C,zkk AS B
WHERE A.hykh = C.hykh
AND C.Kid = b.id
UPDATE hyxx SET FCardTypeName = kmc + '.' + klxmc + '.' + kmc2 + '.' + yhzl WHERE klx > 0
UPDATE hyxx SET FCardTypeName = kmc + '.' + klxmc + '.' + kmc2 + '.' + zkl WHERE klx = 0
--¼Æ´Î¿¨µ¼³ÉÁƳÌ
DROP TABLE TImpItem
--INSERT TImpItem(FItemId,FCourseId) --,FItemNO,FItemName)
SELECT dbo.FNNewId() AS FItemId,
DBO.FNNewId() AS FCourseId,
A.FCardTypeName AS FItemNo,
A.FCardTypeName AS FItemName
INTO TImpItem
FROM hyxx AS A
WHERE klx = 2
GROUP BY A.FCardTypeName
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 FItemId,FItemNo,FItemName,FItemName,FItemName,0,dbo.FNGetFirstPinYin(FItemName),'''',1,1,1,'''','''','''',1,0,0,0,0,0,0,0,1
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,
A.FItemNo + 'L1',
A.FItemName AS FItemName,
'' AS FBriefCode,
A.FItemId 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 A
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 = dbo.FNNewId(),FCardTypeName ,FCardTypeName,CASE WHEN klx = 2 THEN 3 ELSE 1 END,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 hyxx
WHERE klx != 2
GROUP BY FCardTypeName,klx
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 = dbo.FNCompId('001')
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
AND I.FNo like 'MP%'
UPDATE hyxx SET FIsCourse = 0
UPDATE hyxx SET FIsCourse = 1 WHERE klx = 2
--ÁƳÌÀà±ð
UPDATE A
SET A.FCourseId = B.FCourseId,
A.FItemId = B.FItemId
FROM hyxx AS A,TImpItem AS B
WHERE A.FItemName = B.FItemName
AND A.Klx = 2
--´¢Öµ¿¨Àà±ð
UPDATE A
SET A.FCardTypeId = C.FId,
A.FValueType = C.FValueType
FROM hyxx AS A,TMemberCardType AS C
WHERE A.FCardTypeName = c.FName
AND A.FIsCourse = 0
UPDATE hyxx
SET FMemId = 400000 + id,
FMemNo = hykh,
FName = replace(hyxm,' ',''),
FMobilePhone = replace(dbo.FNToDBC(isnull(yddh,'')) ,' ',''),
FBriefCode = isnull(xmjm,''),
FCompId = dbo.FNCompId('001'),
FCreateDate = jrrq,
FGender = case a.xb when 'ÄÐ' then 1 else 0 end ,
FBirthday = a.csrq,
FMemo = isnull(a.lxdz,'') + char(10) + isnull(a.qtxx,'') ,
FPoint = hyjf
FROM hyxx as a
UPDATE hyxx SET FMemNo = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(FMemNo,'£»',''),'£¿',''),'?',''),';',''),' ',''),'£º',''),'','')
--±¸×¢
UPDATE a
SET A.FMemo = isnull(cast(a.bzxx as varchar(1000)),'') + ' ' + isnull(cast(a.qtxx as varchar(1000)),'') + isnull(cast(B.bz as varchar(1000)),'')
FROM hyxx AS A
inner join hyczk AS B ON b.hykh = a.hykh
UPDATE a
SET A.FMemo = isnull(cast(a.bzxx as varchar(1000)),'') + ' ' + isnull(cast(a.qtxx as varchar(1000)),'') + isnull(cast(B.bz as varchar(1000)),'')
FROM hyxx AS A
inner join hyzkk AS B ON b.hykh = a.hykh
--ÃÜÂë,¿¨ID,¿¨×´Ì¬
UPDATE A
SET A.FPW = b.mm,
A.FCardId = 400000 + B.id ,
A.FCardState = case when b.kzt = '²»¿ÉÓÃ' THEN 4 ELSE 1 END
FROM hyxx AS A,hyczk AS B
WHERE A.hykh = b.hykh
UPDATE A
SET
A.FCardId = 420000 + B.id ,
A.FCardState = case when b.kzt = '²»¿ÉÓÃ' THEN 4 ELSE 1 END
FROM hyxx AS A,hyzkk AS B
WHERE A.hykh = b.hykh
--ÃÜÂë,ÓÐЧÆÚ,¿¨ID
SELECT FExpiredDate FROM hyxx
WHERE len(FExpiredDate) != 0
ORDER BY FExpiredDate DESC
UPDATE A
SET A.FExpiredDate = ''
FROM hyxx AS A
UPDATE A
SET A.FExpiredDate = REPLACE(ISNULL(a.dzyj,'9000-12-31'),' ','')
FROM hyxx AS A
UPDATE hyxx
SET FExpiredDate = replace(FExpiredDate,'.','-')
WHERE LEN(FExpiredDate) > 0
UPDATE hyxx
SET FExpiredDate = replace(FExpiredDate,'/','-')
WHERE LEN(FExpiredDate) > 0
UPDATE hyxx
SET FExpiredDate = left(FExpiredDate,4) + '-' + substring(FExpiredDate,5,2) + '-' + right(FExpiredDate,2)
WHERE LEN(dzyj) = 8
AND FExpiredDate NOT LIKE '%.%'
AND FExpiredDate NOT LIKE '%-%'
AND FExpiredDate NOT LIKE '%/%'
AND LEN(FExpiredDate) > 0
UPDATE hyxx
SET FExpiredDate = '2017-03-29 '
WHERE FExpiredDate = '2017-34-29'
UPDATE hyxx
SET FExpiredDate = '2017-12-31'
WHERE FExpiredDate = '201712-31'
UPDATE hyxx
SET FExpiredDate = '2017-12-31'
WHERE FExpiredDate = '2017-1231'
UPDATE hyxx
SET FExpiredDate = '2017-03-29'
WHERE FExpiredDate = '201703-29'
UPDATE hyxx SET FExpiredDate = '9000-01-01' WHERE LEN(FExpiredDate) = ''
--ÁƳ̵ĴÎÊý
UPDATE A
SET A.FRemainTimes = b.dqje
FROM hyxx AS A,hyczk AS B
WHERE A.hykh = b.hykh
AND A.FCalcMode = 1
SELECT * FROM hyczk WHERE kid IN(SELECT FNo FROM TMemberCardType WHERE FValueType = 3)
--´¢Öµ¿¨Óà¶î
UPDATE A
SET A.FBalance = b.dqje
FROM hyxx AS A,hyczk AS B
WHERE A.hykh = b.hykh
AND A.FValueType = 1
UPDATE A
SET A.FRemainTimes = b.dqje
FROM hyxx AS A,hyczk AS B
WHERE A.hykh = b.hykh
AND A.FValueType = 3
UPDATE hyxx SET FMemo = REPLACE(FMemo,'--','')
SELECT FMemNo,FMemo FROM hyxx ORDER BY LEN(FMemo) desc
UPDATE hyxx SET FMemNO = 'C' + FMemNo + ''
WHERE hykh IN(SELECT FMemNO FROM TMember)
SELECT FMemNo INTO #MemNo FROM hyxx WHERE FMemNo IN(SELECT FMemNO FROM TMember)
UPDATE TMember SET FMemNO = 'A' + FMemNO WHERE FMemNo IN(select fmemno from #MemNo)
UPDATE TMemberCard SET FCardNo = 'A' + FCardNo WHERE FCardNo IN(select fmemno from #MemNo)
UPDATE hyxx SET FMemNo = 'B' + FMemNo WHERE FMemNo IN(select fmemno from #MemNo)
--²åÈë»áÔ±
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,
FMemNo,
FName,
FBriefCode,
0 AS FTypeId,
FCompId,
FCreateDate,
FGender,
'G' AS FBirthdayType,
FBirthday,
'' AS FTelephone,
FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
ISNULL(FPW,'') AS FCPW,
ISNULL(FPW,'') AS FQPW,
0 AS FChargeEmpId,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
'',
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from hyxx
--
UPDATE hyxx SET FCompId = 1
ALTER TABLE TMember ALTER COLUMN FMobilePhone VARCHAR(100)
UPDATE hyxx SET FCardNo = FMobilePhone
INSERT INTO dbo.TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FMemNo AS FNo,
FMemNo AS FFaceNo,
FCardTypeId,
FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
FCardState AS FState,
FCreateDate AS FCreateDate,
FExpiredDate AS FExpiredDate,
ISNULL(FRemainTimes,0) AS FTotalTimes,
0 AS FUsedTimes,
0 AS FSaleCompId,
0 AS FSaleBillId,
FMemo AS FMemo
FROM hyxx
WHERE klx != 2
INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT dbo.FNNewId(),FMemId,FCardId AS FCardId,3,ISNULL(FBalance,0),ISNULL(FBalance,0),0,FCreateDate,NULL,''
FROM hyxx
WHERE FIsCourse = 0
INSERT dbo.TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
select dbo.FNNewId(),C.FMemId,A.FCardId,A.FAcctId,getdate(),C.FTypeId,C.FCompId,'DR','Import',0,'',ISNULL(A.FBalance,0),0,ISNULL(A.FBalance,0),0,getdate(),''
from dbo.TMemberCardAccount AS A,dbo.TMemberCard AS C,hyxx AS D
where C.FCardId = A.FCardId
AND C.FCardId = D.FCardId
AND FIsCourse = 0
INSERT dbo.TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCardId,FMemId,FCourseId,0,FItemId,FCompId,FRemainTimes,FRemainTimes,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'',FCalcMode,0
FROM hyxx
WHERE FIsCourse = 1
AND FDeleted = 0
INSERT INTO ZhaoYuan_JingDian.dbo.TMemberCourseHist(FId,FMemId,FMemCourseId,FPackId,FCourseId,FTime,FPurTimes,FFreeTimes,FUsePurTimes,FUseFreeTimes,
FPurAmount,FFreeAmount,FUsePurAmount,FUseFreeAmount,FCompId,
FBillType,FBizType,FTransId,FTransNo,FTransDetailId)
SELECT dbo.FNNewId(),FMemId,FCardId,0,FCourseId,FTime = getdate(),0,0,0,0,
0,0,0,0,1,
'DR','Import',0,'',0
FROM hyxx
WHERE FIsCourse = 1
--½»Ò×ÀúÊ·
TRUNCATE TABLE TMemberOldTransHist
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT isnull(cast(d.id as bigint),dbo.fnnewid()),A.FMemId,B.xfrq,A.FCardId,A.FCompId,'DR','Import',B.fdid,isnull(e.spmc,''),cast(isnull(d.zhje,b.xfje) as decimal(18,6)),1,cast(isnull(zhje,b.xfje) as decimal(18,6)),'','',b.bz
FROM TMemberCard AS A ,hyxx AS C,xfxx AS B
left join xfsp AS D on b.id = d.xfid
left join sp as e on e.id = d.spid
WHERE replace(C.hykh,'','') = B.hykh
AND C.FCardId = A.FCardId
SELECT * FROM TPayACCOUNT
truncate table
select count(1) from xfxx
where hykh not in(select hykh from hyxx)
SELECT * FROM xfsp as b WITH(NOLOCK),xfxx AS A with(nolock),sp AS C
where b.xfid = a.id
AND b.spid = c.id
ORDER BY a.id
SELECT klxmc FROM hyxx group by klxmc ORDER BY klxmc
ALTER TABLE hyxx ADD FCourseId
UPDATE TMemberCard SET FExpiredDate = DATEADD(YEAR,100,FCreateDate)
select * from hyxx WHERE klxmc = 'ͷƤÀíÁÆ¿¨'
SELECT * INTO hyxx FROM master..hyxx
SELECT * INTO xfxx FROM master..xfxx
SELECT * FROM hyxx WHERE klxmc = 'ÆÕͨ¹Ë¿Í'
SELECT * FROM hyxx WHERE bzxx is not null
SELECT * FROM hyxx WHERE hykh = '702058'
SELECT * FROM hyczk WHERE hykh = '702058'
SELECT * FROM hyczk WHERE kzt != '¿ÉÓÃ'
SELECT klxmc FROM hyxx GROUP BY klxmc
SELECT qtxx,lxdz FROM hyxx GROUP BY qtxx
SELECT
SELECT yddh ,sum(1)
from hyxx GROUP BY yddh
SELECT * FROM TCompany WHERE FId = 4734511574699135191
update hyxx SET id = '2000' + cast(id as varchar(20))
SELECT * FROM hyxx
UPDATE hyxx
SET hykh = 'A' + hykh
SET hykh = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(hykh,'£»',''),'£¿',''),'?',''),';',''),' ',''),'£º',''),'A','')
drop table hyxx
SELECT a.id AS FId,
a.hykh AS FNo,
a.hyxm AS FName,
isnull(a.xmjm,'') AS FBriefCode,
0 AS FTypeId,
1 AS FCompId,
a.jrrq AS FCreateDate,
case a.xb when 'ÄÐ' then 1 else 0 end AS FGender,
'G' AS FBirthdayType,
a.csrq AS FBirthday,
'' AS FTelephone,
isnull( replace(dbo.todbc(a.yddh) ,' ',''),'') 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,
isnull(a.lxdz,'') + char(10) + isnull(a.qtxx,'') + char(10) AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from hyxx as a
SELECT hykh,sum(1)
FROM hyxx
group by hykh
order by sum(1) desc
SELECT * FROM hyxx WHERE hykh = '801218'
UPDATE TMemberOldTransHist SET FCompId = 1
SELECT yddh from hyxx order by len(yddh) desc
ALTER TABLE
ALTER TABLE www.ZhaoYuan_JingDian.dbo.TMember ALTER COLUMN FMoiblePhone VARCHAR(50)
INSERT INTO www.ZhaoYuan_JingDian.dbo.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 id AS FId,
hykh AS FNo,
hyxm AS FName,
isnull(xmjm,'') AS FBriefCode,
0 AS FTypeId,
1 AS FCompId,
jrrq AS FCreateDate,
case xb when 'ÄÐ' then 1 else 0 end AS FGender,
'G' AS FBirthdayType,
csrq AS FBirthday,
'' AS FTelephone,
isnull( replace(dbo.todbc(yddh) ,' ',''),'') 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,
isnull(lxdz,'') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from hyxx
SELECT klxmc FROM hyxx group by klxmc ORDER BY klxmc
ALTER TABLE hyxx ADD FCourseId
select * from hyxx WHERE klxmc = '°ü´ÎºÚÓÍ'
alter table hyxx ADD Times int default 0 not null
UPDATE hyxx SET Times = knje,knje = knje * 10 where klxmc = '¼Æ´Î¿¨'
SEL
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
id AS FId,
hykh AS FNo,
hykh AS FFaceNo,
(SELECT FId FROM TMemberCardType WHERE FName = klxmc) AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FName = klxmc) AS FValueType,
1 AS FCompId,
id AS FMemId,
1 AS FState,
jrrq AS FCreateDate,
dateadd(yy,100,jrrq) AS FExpiredDate,
Times AS FTotalTimes,
0 AS FUsedTimes,
0 AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(qtxx,'') AS FMemo
FROM hyxx
INSERT TMemberCardAccount(FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT dbo.FNNewId(),id AS FCardId,3,FBalance,FBalance,0,jrrq,NULL,''
FROM hyxx
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
select dbo.FNNewId(),C.FMemId,A.FCardId,A.FAcctId,getdate(),C.FTypeId,C.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),''
from TMemberCardAccount AS A,TMemberCard AS C,hyxx AS D
where C.FId = A.FCardId
AND C.FId = D.id
SELECT * FROM TMemberCardAccount
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT id,A.FMemId,xfrq,A.FCardId,A.FCompId,'DR','Import','','',cast(dzhje as decimal(18,6)),1,cast(dzhje as decimal(18,6)),'','',bz
FROM xfxx1a,TMemberCard AS A
WHERE A.FCardNo = hykh
INSERT TMemberPointHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FMemo,FRecordTime)
SELECT dbo.FNNewId(),A.FMemId,getdate(),0,1,'DR','Import',0,'',FPoint,0,FPoint,'',getdate()
FROM hyxx AS A
WHERE FPoint != 0
AND FMemId IN (SELECT FMemId FROM TMember)
select * from xfxx2
update xfxx2 set hykh = 'A' + hykh
Truncate table TMemberOldTransHist
select * from xfxx
SELECT * FROM TMemberOld
select dateadd(yy,100,getdate())
UPDATE TMemberCard SET FExpiredDate = dateadd(yy,100,FCreateDate)
insert gcm12
(gcn00c,gcn01c,gcn02c,gcn09f,gcn10i,gcn12d,gcn13d,gcn15c,gcn17c,gcn22i,gcn24i,gcn04c,gcn06i,gcn03c,gcn16f)
select
'003',hykh,'0',knje,'0',jrrq,'22000101',hykh,'003','1','1',yddh,xb,hyxm,hyjf
from gcm12_01
UPDATE hyxx SET FPoint = hyjf
UPDATE TMemberCard SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003')
UPDATE TMember SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003')
DELETE TMember WHERE FMemId > 0
UPDATE TMemberCardAcctHist SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003')
SELECT * FROM TMemberSaleDetailPayment
UPDATE #Member SET FNo = REPLACE(FNo,'A','') WHERE FNo LIKE 'A%'
UPDATE #Member SET FNo = 'A' + FNo
WHERE FNo IN (SELECT FNo FROM TMember WHERE FCompId != 4734511574699135191)
SELECT * FROM #Member WHERE FNo like 'A%'
UPDATE B
SET B.FNo = 'A' + B.FNo
FROM #Member AS B,
(
SELECT FNo, COUNT(1) as cnt,max(FId) as FId FROM #Member
GROUP BY FNo
) AS A
WHERE cnt > 1
AND B.FId = A.FId
--ÁƳÌ
--ÁƳÌ
ALTER TABLE hyxx ADD FCourseCardId BIGINT
UPDATE hyxx SET FCourseCardId = dbo.FNNewId()
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCourseCardId,FMemId,FCourseId,0,FItemId,FCompId,FRemainTimes,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'µ¼Èë',1,0
FROM hyxx AS A
WHERE klx = 2
ALTER TABLE hyxx ADD FPurTimes FLOAT
UPDATE A
SET A.FPurTimes = B.
SELECT * FROM hyczk
SELECT * FROM hyxx
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.FCourseCardId AS FCardId,0, ISNULL(FCourseId,0),getdate(),FRemainTimes,0,0,0,FCompId,'DR','Import',0,'',0,getdate()
FROM hyxx AS A
WHERE klx= 2
--ÁƳÌ×ÊÁÏ
SELECT * FROM sp
INSERT TImpItem(FItemId,FCourseId,FItemNo,FItemName)
SELECT dbo.FNNewId(),dbo.FNNewId(),spmc,spmc
FROM sp
WHERE id IN(SELECT spid FROM hyjc)
GROUP BY spmc
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 FItemId,FItemNo,FItemName,FItemName,FItemName,0,dbo.FNGetFirstPinYin(FItemName),'''',1,1,1,'','','',1,0,0,0,0,0,0,0,1
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,
A.FItemNo + 'L1',
A.FItemName AS FItemName,
'' AS FBriefCode,
A.FItemId 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 A
ALTER TABLE hyjc ADD FMemId BIGINT
ALTER TABLE hyjc ADD FcARDId BIGINT
ALTER TABLE hyjc ADD FCourseId BIGINT
ALTER TABLE hyjc ADD FPurTimes DECIMAL(18,6)
ALTER TABLE hyjc ADD FUsedPurTimes DECIMAL(18,6)
ALTER TABLE hyjc ADD FPurAmount DECIMAL(18,6)
ALTER TABLE hyjc ADD FCompId BIGINT
ALTER TABLE hyjc ADD FItemId BIGINT
ALTER TABLE hyjc ADD FCreateDate DATETIME
ALTER TABLE hyjc ADD FExpiredDate DATETIME
ALTER TABLE hyjc ADD FAdjustPrice DECIMAL(18,6)
UPDATE A
SET A.FCourseId = B.FCourseId,
A.FItemId = B.FItemId
FROM hyjc AS A,TImpItem AS B,sp AS C
WHERE A.spid = c.id
AND B.FItemName = C.spmc
SELECT * FROM hyjc
UPDATE A
SET A.FMemId = B.FMemId,
A.FCompId = B.FCompId
FROM hyjc AS A,hyxx AS B
WHERE A.hykh = B.hykh
UPDATE hyjc SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE hyjc SET FCreateDate = rq
UPDATE hyjc SET FPurTimes = cs
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCardId,FMemId,FCourseId,0,FItemId,FCompId,FPurTimes,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'µ¼Èë',1,0
FROM hyjc AS A
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(FCourseId,0),getdate(),FPurTimes,0,0,0,FCompId,'DR','Import',0,'',0,getdate()
FROM hyjc AS A