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/柏士高new_基本资料.sql

524 lines
19 KiB

1 year ago
use yintai_mangguo
select * from imp_member_list
select m_shop_name into imp_company from imp_member_list
group by m_shop_name
ALTER TABLE imp_company ADD comp_id bigint
select * from imp_company
UPDATE A
SET A.comp_id = b.FId
FROM imp_company AS A,TCompany AS B
WHERE A.m_shop_name LIKE '%' + b.FAbbr + '%'
AND B.FId > 0
--<EFBFBD><EFBFBD>Ա
ALTER TABLE imp_member ADD mem_id BIGINT
ALTER TABLE imp_member ADD card_id BIGINT
ALTER TABLE imp_member ADD card_type_name VARCHAR(100)
ALTER TABLE imp_member ADD mem_no VARCHAR(50)
ALTER TABLE imp_member ADD card_No VARCHAR(50)
ALTER TABLE imp_member ADD name VARCHAR(50)
ALTER TABLE imp_member ADD gender INT
ALTER TABLE imp_member ADD mobile VARCHAR(50)
ALTER TABLE imp_member ADD birthday_type VARCHAR(50)
ALTER TABLE imp_member ADD birthday DATETIME
ALTER TABLE imp_member ADD comp_id BIGINT
ALTER TABLE imp_member ADD card_type_id BIGINT
ALTER TABLE imp_member ADD memo VARCHAR(MAX)
ALTER TABLE imp_member ADD balance DECIMAL(18,6)
ALTER TABLE imp_member ADD balance2 DECIMAL(18,6)
ALTER TABLE imp_member ADD point DECIMAL(18,6)
ALTER TABLE imp_member ADD arrear DECIMAL(18,6)
ALTER TABLE imp_member ADD create_date datetime
ALTER TABLE imp_member ADD expire_date datetime
UPDATE imp_member SET mem_id = dbo.fnnewid() where mem_id is null
UPDATE imp_member SET card_id = dbo.fnnewid() where card_id is null
UPDATE imp_member SET name = m_realname
UPDATE imp_member SET mem_no = m_number
UPDATE imp_member SET mobile = m_telphone
UPDATE imp_member SET create_date = m_regdate
UPDATE imp_member SET expire_date = dateadd(year,100,create_date);
UPDATE imp_member SET gender = case when m_sex = '<EFBFBD><EFBFBD>' then 1 else 0 end
update imp_member SET balance = replace(m_extcredits1,'Ԫ','')
update imp_member SET balance2 = replace(m_extcredits2,'Ԫ','')
update imp_member SET arrear = replace(m_extcredits3,'Ԫ','')
update imp_member SET memo = m_intro
update imp_member SET birthday_type = 'G'
update imp_member SET card_type_id = 5862079485731044400
UPDATE A
SET A.comp_id = B.comp_id
FROM imp_member AS A,imp_company AS B
WHERE a.m_shop_name = b.m_shop_name
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 mem_id AS FMemId,
mem_no AS FMemNo,
name AS FName,
dbo.FNGetFirstPinYin(name),
0 AS FTypeId,
comp_id AS FCompId,
create_date AS FCreateDate,
gender AS FGender,
birthday_type AS FBirthdayType,
birthday AS FBirthday,
'' AS FTelephone,
ISNULL(mobile,'') 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,
memo AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from imp_member
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
card_id AS FId,
mem_no AS FNo,
card_type_id AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = card_type_id) AS FValueType,
comp_id AS FCompId,
mem_id AS FMemId,
1 AS FState,
create_date AS FCreateDate,
expire_date AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
comp_id AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM imp_member
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT mem_id,dbo.FNNewId(),card_id AS card_id,3,balance,balance,0,create_date,NULL AS FExpiredDate,''
FROM imp_member
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
select dbo.FNNewId(),A.mem_id,A.card_id,3,getdate(),A.card_type_id,A.comp_id,'DR','Import',0,'',A.balance,0,A.balance,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM imp_member AS A
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT mem_id,dbo.FNNewId(),card_id AS FCardId,10,balance2,balance2,0,create_date,NULL AS FExpiredDate,''
FROM imp_member
WHERE balance2 > 0
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
select dbo.FNNewId(),A.mem_id,A.card_id,10,getdate(),A.card_type_id,A.comp_id,'DR','Import',0,'',A.balance2,0,A.balance2,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM imp_member AS A
WHERE balance2 > 0
SELECT * FROM imp_member
where m_member_id not in(select m_member_id from imp_member_course)
SELECT COUNT(1) FROM imp_member_course
insert imp_item
select dbo.FNNewId() AS id,dbo.FNNewId() AS course_id, '' + product_name AS no, product_name AS name
INTO imp_item
from imp_member_course
where product_name not in(select name from imp_item)
GROUP BY product_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 id,no,name,name,name,0,dbo.FNGetFirstPinYin(name),'''',1,1,1,'''','''','''',1,0,0,0,0,0,0,0,1
FROM imp_item
WHERE id not in(select fid from titem)
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT course_id AS FId,
I.no + '',
I.name AS FName,
'' AS FBriefCode,
I.id 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 imp_item AS I
WHERE course_id not in(select fid from TCourse)
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 C.FNo = '009'
AND NOT EXISTS(SELECT TOP 1 1 FROM TItemSub AS B WHERE B.FCompId = C.FId AND B.FItemId = I.FId)
AND I.FId IN(SELECT id from imp_item)
ALTER TABLE imp_member_course ADD mem_id BIGINT
ALTER TABLE imp_member_course ADD card_id BIGINT
ALTER TABLE imp_member_course ADD course_id BIGINT
ALTER TABLE imp_member_course ADD remain_Times DECIMAL(18,6)
ALTER TABLE imp_member_course ADD Used_Pur_Times DECIMAL(18,6)
ALTER TABLE imp_member_course ADD Pur_Amount DECIMAL(18,6)
ALTER TABLE imp_member_course ADD Comp_Id BIGINT
ALTER TABLE imp_member_course ADD Item_Id BIGINT
ALTER TABLE imp_member_course ADD Pur_Times DECIMAL(18,6)
ALTER TABLE imp_member_course ADD Adjust_Price DECIMAL(18,6)
ALTER TABLE imp_member_course ADD create_date datetime
ALTER TABLE imp_member_course ADD expire_date datetime
UPDATE imp_member_course SET card_id = dbo.FNNewId() WHERE card_id is null
UPDATE A
SET A.item_id = B.Id,
A.Course_Id = B.Course_Id
FROM imp_member_course AS A,imp_item AS B
WHERE A.product_name = B.name
UPDATE A
SET A.mem_id = B.mem_id
FROM imp_member_course AS A,imp_member AS B
WHERE A.m_member_id = B.m_member_id
select * from imp_member_course where mem_id is null
UPDATE imp_member_course SET pur_Times = 0 ,remain_Times = 0
UPDATE imp_member_course SET pur_Times = mp_number_total where mp_number_total not like '%<EFBFBD><EFBFBD>%'
UPDATE imp_member_course SET remain_Times = mp_number where mp_number not like '%<EFBFBD><EFBFBD>%'
UPDATE imp_member_course SET pur_amount = replace(mp_cost,'Ԫ','')
UPDATE imp_member_course SET adjust_price = pur_amount / pur_times where pur_times > 0
UPDATE A
SET A.comp_id = b.comp_id
FROM imp_member_course AS a,imp_company AS B
WHERE a.mp_shop_name = b.m_shop_name
select * from imp_member_course
UPDATE imp_member_course SET create_date = mp_dateline
UPDATE imp_member_course SET expire_date = mp_expiry_dateline where mp_expiry_dateline not like '%font%'
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT card_id,mem_id,course_id,0,item_id,comp_id,Pur_Times,ISNULL(Pur_Amount,0),0,Pur_Times - Remain_Times,0,Create_Date,Expire_Date,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,ISNULL(Adjust_Price,0)
FROM imp_member_course
--WHERE FCourseId IS NOT NULL
WHERE mem_id IS NOT NULL
UPDATE A
SET A.FCalcMode = 2
FROM TMemberCourse AS A,TImpmemberCourse AS B
WHERE A.FId = B.FId
AND B.code != 1
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),Mem_Id,card_Id,0,Course_Id,FTime = getdate(),Pur_Times,Pur_Times - Remain_Times,0,0,
comp_id,
'DR','Import',0,'',0
FROM imp_member_course
WHERE mem_id is not null
SELECT * FROM imp_serve
drop table imp_serve
ALTER TABLE imp_serve ADD serve_Id BIGINT
ALTER TABLE imp_serve ADD card_type_id BIGINT
ALTER TABLE imp_serve ADD price DECIMAL(18,6)
ALTER TABLE imp_serve ADD vip_price DECIMAL(18,6)
ALTER TABLE imp_serve ADD name nvarchar(100)
UPDATE imp_serve SET serve_Id = dbo.FNNewId()
UPDATE imp_serve SET card_type_id = dbo.FNNewId()
UPDATE imp_serve SET price = 0 where product_cost= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_serve SET vip_price = 0 where product_vip_cost= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_serve SET price = cast(replace(product_cost,'Ԫ','') as float)where product_cost!= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_serve SET vip_price = cast(replace(product_vip_cost,'Ԫ','') as float)where product_vip_cost!= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_serve SET name = product_name
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 serve_Id,name,name,name,name,0,FBriefCode = dbo.FNGetFirstPinYin(name),
FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '',
FCustom3 = '',FEnabled = 1,price ,FVipPrice = vip_price ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0,
FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1
FROM imp_serve
UPDATE imp_serve
SET name = name + '_' + pos_name + '_' + product_cost
WHERE name in(
select name from imp_serve
group by name
having sum(1) > 1
)
SELECT * FROM imp_serve
WHERE name = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>280Ԫ'
IN(
DELETE A
FROM imp_serve AS A,(
SELECT <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,MIN(FItemId)AS FItemId
FROM imp_serve
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 imp_serve 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 card_type_id,
name + '' AS FNo,
name + '' 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 imp_serve 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>Ʒ
INSERT TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FEnabled)
SELECT dbo.FNNewId(),'GoodsType', product_pinpai,product_pinpai,0,'','','',1,-1,1 FROM imp_product
WHERE product_pinpai > ''
group by product_pinpai
union all select dbo.FNNewId(),'GoodsType', '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0,'','','',1,-1,1
ALTER TABLE imp_product ADD serve_Id BIGINT
ALTER TABLE imp_product ADD price DECIMAL(18,6)
ALTER TABLE imp_product ADD vip_price DECIMAL(18,6)
ALTER TABLE imp_product ADD name nvarchar(100)
ALTER TABLE imp_product ADD product_type_id bigint
UPDATE imp_product SET serve_Id = dbo.FNNewId()
UPDATE imp_product SET price = 0 where product_cost= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_product SET vip_price = 0 where product_vip_cost= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_product SET price = cast(replace(product_cost,'Ԫ','') as float)where product_cost!= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_product SET vip_price = cast(replace(product_vip_cost,'Ԫ','') as float)where product_vip_cost!= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE imp_product SET name = product_name
UPDATE a
set a.product_type_id = B.FId
FROM imp_product as a,TBasicType AS B
WHERE a.product_pinpai = b.FName
AND B.FKey = 'GoodsType'
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,FIsSale,FUnitLock,FDescription,FCustom1,FCustom2,FCustom3)
SELECT dbo.FNNewId(),name,name,name,min(product_type_id),dbo.FNGetFirstPinYin(name),
20006,min(price),FPurCostPrice = 0,FSaleCostPrice = 0,FConsCostPrice = 0,
FValuationMode = 0,FBarCode = 0,FEnabled = 1,FSpecification = '',
FPurUnitId = 0,FConsUnitId = 0,FSupplierId = 0,FStoreId = 0,FConsStoreId= 0,FSaleStoreId= 0,
FMaxStock= 0,FMinStock= 0,FPeriodEnabled= 0,FShelfLife= 0,FDctId= 0,FPointMode= 0,FPointValue= 0,
FDeptId= 0,1,FUnitLock= 0,FDescription= '',FCustom1 = '',FCustom2 = '',FCustom3 = ''
FROM imp_product
group by name
INSERT INTO TGoodsMultiUnit(FId,FGoodsId,FUnitType,FUnitId,FSequence,FConvDir,FConvRate,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FBarCode,FUnitLock)
SELECT dbo.FNNewId(),FId,1,FUnitId,1,1,1,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FBarCode,FUnitLock
FROM TGoods
--Ա<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
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 C.FNo = '009'
AND NOT EXISTS(SELECT TOP 1 1 FROM TGoodsSub AS B WHERE B.FCompId = C.FId AND B.FGoodsId = I.FId)
-- AND C.FId = 1