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

903 lines
29 KiB

1 year ago
use yintai_mangguo
alter table uni_member alter column memberid int
CREATE INDEX IX_uni_member_memberid on uni_member(memberid)
alter table uni_member_count alter column memberid int
CREATE INDEX IX_uni_member_count_memberid on uni_member_count(memberid)
SELECT * FROM uni_shop
select * from uni_product
WHERE product_name IN(SELECT FName FROM TItem)
select * from uni_product
WHERE product_name IN(SELECT REPLACE(FNo,'<EFBFBD><EFBFBD>ɾ1','') + '-' + FName FROM TItem)
select * from uni_product
WHERE product_name IN()
DROP TABLE #Course
select * from uni_member where mem_No= '290407826'
select * from uni_member where m_main_memberid = 11087
SELECT * FROM uni_member WHERE m_status = -2
UPDATE TMemberCard SET FCardNo = FCardNo + '[<EFBFBD><EFBFBD>ϵͳͣ<EFBFBD><EFBFBD>]',FDeleted = 1, FState = 4,FMemo = FMemo + '[<EFBFBD><EFBFBD>ϵͳ<EFBFBD>о<EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>]'
WHERE FCardId IN(SELECT card_Id FROM uni_member WHERE m_status= -2)
UPDATE TMemberCourse SET FDeleted = 1, FState = 4,FMemo = FMemo + '[<EFBFBD><EFBFBD>ϵͳ<EFBFBD>о<EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>]'
WHERE FId IN(SELECT card_Id FROM uni_member_product WHERE mp_status= -2)
SELECT * FROM uni_member WHERE m_number = '290405797'
SELECT * FROM uni_member WHERE m_main_memberid = '44653'
SELECT * FROM uni_member_product where memberid = 44653
SELECT * FROM uni_member_product where memberid = 44655
SELECT * FROM uni_member_product where memberid = 44654
update
pinitdefaultnullitem
pinitdefaultvisitor
select
SELECT * FROM uni_member_count
SELECT count(1) FROM uni_member
where m_ismain = 1
AND m_type = 0
SELECT * FROM uni_member
where m_ismain = 0
AND m_type = 0
and m_card_name = ''
UPDATE uni_member set m_card_name = '' where m_card_name = '<EFBFBD>޿<EFBFBD><EFBFBD><EFBFBD>'
SELECT * FROM uni_member
where m_realname = '<EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD>'
AND m_telphone = '13793521689'
SELECT * FROM uni_member_count where memberid = 139222
SELECT * FROM uni_member where memberid = 139222
SELECT top 10 * FROM uni_member where m_ismain = 0 and m_main_memberid = memberid
SELECT * FROM uni_member where uid != 'NULL' and m_ismain = 0 and m_main_memberid = memberid
SELECT top 100 * FROM uni_member where uid = 'NULL' and m_ismain = 1 and m_main_memberid != memberid
SELECT top 100 * FROM uni_member where uid = 'NULL' and m_ismain = 0 and m_main_memberid != memberid
SELECT top 100 * FROM uni_member where m_ismain = 1 and m_remark != ''
SELECT memberid from uni_member
group by memberid
having sum(1) > 1
SELECT DATEADD(SECOND,cast(m_vip_open as bigint),'1970-01-01')
FROM uni_member
SELECT * FROM uni_member
where m_vip_expire = 0
select * from uni_member where memberid = 66067
SELECT * FROM uni_member_count where memberid = 1944
select * from uni_order
delete a
from uni_member as a,(select memberid,max(idx) as idx from uni_member group by memberid having sum(1) > 1) as b
where a.memberid = b.memberid
and a.idx != b.idx
alter table uni_member add idx int identity
delete uni_member_product
select * from TItem WHERE FDeleted = 1
U77L6-<EFBFBD><EFBFBD>ë<EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
select * from TCourse WHERE FName like '%<EFBFBD><EFBFBD>ë<EFBFBD>꿨%'
delete TItem
WHERE FNo = FName
SELECT * INTO #Item FROM TItem WHERE FNo = FName
DELETE TCourse WHERE FItemId IN(SELECT FId FROM #Item)
DELETE TItem WHERE FId IN(SELECT FId FROM #Item)
pclearmemberdata
use yintai_mangguo
select * from uni_member_list
--<EFBFBD>ŵ<EFBFBD>
alter table uni_shop add comp_id bigint
UPDATE A
SET A.comp_id = b.FId
FROM uni_shop AS A,TCompany AS B
WHERE A.shop_name LIKE '%' + b.FAbbr + '%'
AND B.FId > 0
--<EFBFBD><EFBFBD>Ա
ALTER TABLE uni_member ADD mem_id BIGINT
ALTER TABLE uni_member ADD card_id BIGINT
ALTER TABLE uni_member ADD card_type_name VARCHAR(100)
ALTER TABLE uni_member ADD mem_no VARCHAR(50)
ALTER TABLE uni_member ADD card_No VARCHAR(50)
ALTER TABLE uni_member ADD name VARCHAR(50)
ALTER TABLE uni_member ADD gender INT
ALTER TABLE uni_member ADD mobile VARCHAR(50)
ALTER TABLE uni_member ADD birthday_type VARCHAR(50)
ALTER TABLE uni_member ADD birthday DATETIME
ALTER TABLE uni_member ADD comp_id BIGINT
ALTER TABLE uni_member ADD card_type_id BIGINT
ALTER TABLE uni_member ADD memo VARCHAR(MAX)
ALTER TABLE uni_member ADD balance DECIMAL(18,6)
ALTER TABLE uni_member ADD balance2 DECIMAL(18,6)
ALTER TABLE uni_member ADD point DECIMAL(18,6)
ALTER TABLE uni_member ADD arrear DECIMAL(18,6)
ALTER TABLE uni_member ADD create_date datetime
ALTER TABLE uni_member ADD register_date datetime
ALTER TABLE uni_member ADD expire_date datetime
ALTER TABLE uni_member ADD total_times int
select top 11* from uni_member
where m_use_surplus > 0
UPDATE uni_member SET mem_id = dbo.fnnewid() where mem_id is null
UPDATE uni_member SET card_id = dbo.fnnewid() where card_id is null
UPDATE uni_member SET name = m_realname
UPDATE uni_member SET mem_no = m_number
UPDATE uni_member SET card_no = m_number
UPDATE uni_member SET mobile = m_telphone
UPDATE uni_member SET register_date = dateadd(second,cast(m_regdate as bigint),'1970-01-01')
UPDATE uni_member SET create_date = dateadd(second,cast(m_vip_open as bigint),'1970-01-01')
UPDATE uni_member SET expire_date = dateadd(second,cast(m_vip_expire as bigint),'1970-01-01')
UPDATE uni_member SET expire_date = dateadd(year,100,create_date) where expire_date = '1970-01-01'
UPDATE uni_member SET gender = case when m_sex = '1' then 1 else 0 end
update uni_member SET memo = m_remark
update uni_member SET birthday_type = 'G'
update uni_member SET total_times = m_use_surplus
update a
set a.mem_id = b.mem_id
from uni_member as a,uni_member as b
where a.m_ismain = 0
and b.m_ismain = 1
and a.m_main_memberid = b.memberid
and a.m_type = 0
SELECT * FROM uni_member
where balance2 > 0
and card_id not in(select fcardid from tmembercardaccount)
SELECT * FROM uni_member where m_main_memberid = 159255
SELECT SUm(FBalance)-31114385.69 FROM TMemberCardAccount
WHERE FAcctId = 3
SELECT SUm(FBalance) - 3169619.000000 FROM TMemberCardAccount
WHERE FAcctId = 10
SELECT SUM(balance2) from uni_member
SELECT * FROM uni_member where balance2 < 0
update a
SET balance = extcredits1 / 100,
balance2 = extcredits2 / 100,
arrear = extcredits3 / -100
from uni_member as a,uni_member_count as b
where a.memberid = b.memberid
select sum(balance),sum(balance2),sum(arrear)
from uni_member
update a
set a.card_type_id = b.FId
FROM uni_member AS a,TMemberCardType AS B
WHERE a.m_card_name = REPLACE(b.FNo,'<EFBFBD><EFBFBD>ɾ1','') + '-' + b.FName
or a.m_card_name = b.fname
or (a.m_card_name = '' and ( a.balance > 0 or a.balance2 > 0) and b.Fname = 'δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE A
SET A.comp_id = B.comp_id
FROM uni_member AS A,uni_shop AS B
WHERE a.shopid = b.shopid
UPDATE uni_member SET comp_id = 1 WHERE shopid = 2
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,
register_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 uni_member
WHERE m_ismain = 1
and m_type = 0
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
card_id AS FId,
card_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,
total_times AS FTotalTimes,
0 AS FUsedTimes,
comp_id AS FSaleCompId,
0 AS FSaleBillId,
memo AS FMemo
FROM uni_member
where (m_card_name != '' or (m_ismain = 1 and (balance > 0 or balance2 > 0)))
and mem_id in(select FMemId FROM TMember)
delete TMemberCardAcctHist
delete TMemberCardAccount
delete TMemberCard
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 uni_member
WHERE card_id in(select FCardId FROM TMemberCard)
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 uni_member AS A
WHERE card_id in(select FCardId FROM TMemberCard)
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 uni_member
WHERE balance2 > 0
and card_id in(select FCardId FROM TMemberCard)
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 uni_member AS A
WHERE balance2 > 0
and card_id in(select FCardId FROM TMemberCard)
--<EFBFBD>Ƴ<EFBFBD>
alter table uni_member_product alter column memberid int
create index ix_uni_member_product_memberId on uni_member_product(memberid)
ALTER TABLE uni_member_product ADD mem_id BIGINT
ALTER TABLE uni_member_product ADD card_id BIGINT
ALTER TABLE uni_member_product ADD course_id BIGINT
ALTER TABLE uni_member_product ADD remain_Times DECIMAL(18,6)
ALTER TABLE uni_member_product ADD Used_Pur_Times DECIMAL(18,6)
ALTER TABLE uni_member_product ADD Pur_Amount DECIMAL(18,6)
ALTER TABLE uni_member_product ADD Comp_Id BIGINT
ALTER TABLE uni_member_product ADD Item_Id BIGINT
ALTER TABLE uni_member_product ADD Pur_Times DECIMAL(18,6)
ALTER TABLE uni_member_product ADD Adjust_Price DECIMAL(18,6)
ALTER TABLE uni_member_product ADD calc_mode int
ALTER TABLE uni_member_product ADD create_date datetime
ALTER TABLE uni_member_product ADD expire_date datetime
--ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
alter table uni_member_product add deleted bit not null default 0
update uni_member_product set deleted = 0
drop table #m
select memberid into #m from uni_member where mem_id in(select fmemid from TMember)
group by memberid
update uni_member_product set deleted = 1
where memberid not in(select memberid from #m)
update uni_member_product set deleted = 1 where productid = 250 --<EFBFBD>Ƴ̴<EFBFBD>ֵ<EFBFBD><EFBFBD>
--<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
select * into imp_product
from uni_product
where productid in(select productid from uni_member_product where deleted = 0)
alter table imp_product add name nvarchar(100)
alter table imp_product add item_id bigint
alter table imp_product add card_type_id bigint
update imp_product set name = product_name
update imp_product set name = substring(product_name,charindex('-',product_name)+1,len(product_name))
where product_name <= 'Z'
and product_name not in(select fname from TItem)
and product_name not in(select fname from TCourse)
update a
set a.name = a.name + '[' + b.pos_name + ']'
from imp_product as a,uni_staff_position as b
where a.product_posid = b.posid
update imp_product set name = replace(name,'[<EFBFBD><EFBFBD>]','(<EFBFBD><EFBFBD>)')
update imp_product set name = replace(name,'[Ů]','(Ů)')
update imp_product set card_type_id = 0
update a
set a.card_type_id = b.FId,
a.item_id = b.FItemId
FROM TCourse AS B,imp_product as a
where a.name =b.fname
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT dbo.FNNewId() AS FId,
I.FNo + '',
I.FName AS FName,
'' AS FBriefCode,
I.FId 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 TItem AS I
WHERE FName IN(select name from imp_product where card_type_id = 0)
alter table imp_product add is_new bit not null default 0
update imp_product set is_new = 1 where card_type_id = 0
SELECT dbo.FNNewId() as item_id,name,dbo.FNnewId() as card_type_id
into imp_item
FROM imp_product
WHERE is_new = 1
group by name
UPDATE a
set item_id = b.item_id,a.card_type_id = b.card_type_id
from imp_product as a,imp_item as b
where a.name = b.name
and a.is_new = 1
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 item_id,name,name,name,name,0,dbo.FNGetFirstPinYin(name),'',1,1,1,'','','',1,0,0,0,0,0,0,0,1
FROM imp_item
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 AS FId,
I.name + '',
I.name AS FName,
'' AS FBriefCode,
I.item_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
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 item_id from imp_item)
UPDATE uni_member_product SET card_id = dbo.FNNewId() WHERE card_id is null
UPDATE A
SET A.item_id = B.item_id,
A.Course_Id = B.card_type_id
FROM uni_member_product AS A,imp_product AS B
WHERE A.productid = B.productid
UPDATE A
SET A.mem_id = B.mem_id
FROM uni_member_product AS A,uni_member AS B
WHERE A.memberid = B.memberid
UPDATE uni_member_product SET pur_Times = 0 ,remain_Times = 0
UPDATE uni_member_product SET pur_Times = mp_number_total where mp_number_total >= 0
UPDATE uni_member_product SET remain_Times = mp_number where mp_number >= 0
UPDATE uni_member_product SET pur_amount = mp_cost / 100
UPDATE uni_member_product SET adjust_price = pur_amount / pur_times where pur_times > 0
UPDATE uni_member_product SET calc_mode = 1
UPDATE uni_member_product SET calc_mode = 2 where mp_number = -99
UPDATE A
SET A.comp_id = b.comp_id
FROM uni_member_product AS a,uni_shop AS B
WHERE a.shopid = b.shopid
UPDATE uni_member_product SET create_date = dateadd(second,cast(mp_dateline as bigint),'1970-01-01')
UPDATE uni_member_product SET expire_date = dateadd(second,cast(mp_expiry_dateline as bigint),'1970-01-01')
update uni_member_product set expire_date = null where mp_expiry_dateline = 0
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,memo + '[<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>]',calc_mode,ISNULL(Adjust_Price,0)
FROM uni_member_product
--WHERE FCourseId IS NOT NULL
WHERE mem_id in(select fmemid from TMember)
and deleted = 0
select * from uni_member_product where mp_remark != ''
UPDATE A
SET A.FMemo = '[<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>]' + b.mp_remark
FROM TMemberCourse AS A,uni_member_product as b
where a.fid = b.card_id
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 uni_member_product
WHERE mem_id in(select fmemid from TMember)
and deleted = 0
UPDATE TItem SET FDeleted
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
delete uni_product
SELECT * FROM uni_product
where product_name like '%<EFBFBD><EFBFBD>%'
where product_name in(select m_card_name from uni_member)
SELECT * FROM TMemberCardType
WHERE REPLACE(FNo,'<EFBFBD><EFBFBD>ɾ1','') + '-' + FName
IN(select m_card_name from uni_member )
OR FName IN(select m_card_name from uni_member)
select m_card_name from uni_member
where m_card_name not in(select REPLACE(FNo,'<EFBFBD><EFBFBD>ɾ1','') + '-' + FName from tmemberCardType)
and m_card_name not in(select FName from tmemberCardType)
group by m_card_name
SELECT * FROM TMemberCardType WHERE FName like '%<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>%'
ALTER TABLE uni_order ADD mem_id BIGINT
ALTER TABLE uni_order ADD comp_id BIGINT
ALTER TABLE uni_order_products add content nvarchar(1000)
UPDATE A
SET A.mem_id = b.mem_id
FROM uni_order AS A,uni_member AS B
WHERE a.order_main_Memberid = b.memberid
UPDATE A
SET A.comp_id = b.comp_id
FROM uni_order AS A,uni_shop AS B
WHERE a.shopid = b.shopid
alter table uni_order alter column orderid varchar(30)
create index ix_uni_order_order_id on uni_order(orderid)
alter table uni_order_products alter column orderid varchar(30)
create index ix_uni_order_products_order_id on uni_order_products(orderid)
alter table uni_order_Products alter column productid varchar(30)
create index ix_uni_order_Products_product_id on uni_order_Products(productid)
alter table uni_product alter column productid varchar(30)
create index ix_uni_Product_product_id on uni_product(productid)
UPDATE A
SET A.content = B.product_name
FROM uni_order_products as a,uni_product as b
where a.productid = b.productid
SELECT * FROM uni_shop
SELECT * FROM uni_order as a,uni_order_Products as b
where a.orderid = b.orderid
SELECT * FROM uni_order_Products
where content is null
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT DBO.FNNewId(),A.mem_Id,dateadd(second,cast(order_clearing_dateline as bigint),'1970-01-01'),0,A.comp_id,'DR','Import',order_number_custom,isnull(content,''),order_cost_real,1,order_cost_real,isnull(order_pay_type,''),order_staff_custom,order_remark
FROM uni_order AS A ,uni_order_Products as b
where a.orderid = b.orderid
and a.mem_id is not null
select * from uni_order where orderid = 5954