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/PStyle/pstyle.sql

967 lines
46 KiB

use beijing_pstyle
SELECT * FROM t_mem_member_0 where member_no = '18911026435'
SELECT * FROM t_mem_member where mobile = '18911026435'
SELECT * FROM T_BUS_VC_001
SELECT * FROM T_BUS_VC
SELECT * FROM T_BUS_VC_TPL
drop table t_mem_member_002
drop table T_BUS_VC_001
SELECT * FROM T_BUS_VC where member_id = 2999
SELECT count(1) FROM T_BUS_CONSUME_REC
DROP TABLE T_BUS_CONSUME_REC
SELECT * FROM T_BUS_CONSUME_REC where member_id = 2999
select remainCashValue + remainDonateValue t_mem_member where member_no = '18911026435'
select sum(cast(remain_available_value as float))
from t_mem_member
select remain_charged_value from t_mem_member where member_no = '18911026435'
SELECT * FROM t_mem_member
SELECT * FROM T_BUS_VC
exec sp_rename 't_mem_member','t_mem_member_001'
exec sp_rename 'T_BUS_VC','T_BUS_VC_003'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_003'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_001'
exec sp_rename 'T_SYS_CARD_TYPE','T_SYS_CARD_TYPE_003'
exec sp_rename 't_mem_member','t_mem_member_003'
exec sp_rename 'T_BUS_VC','T_BUS_VC_003'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_003'
exec sp_rename 't_mem_member','t_mem_member_002'
exec sp_rename 'T_BUS_VC','T_BUS_VC_002'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_002'
exec sp_rename 't_mem_member','t_mem_member_001'
exec sp_rename 'T_BUS_VC','T_BUS_VC_001'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_001'
exec sp_rename 't_mem_member','t_mem_member_004'
exec sp_rename 'T_BUS_VC','T_BUS_VC_004'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_004'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_004'
exec sp_rename 'T_SYS_CARD_TYPE','T_SYS_CARD_TYPE_004'
exec sp_rename 't_mem_member','t_mem_member_005'
exec sp_rename 'T_BUS_VC','T_BUS_VC_005'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_005'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_005'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_005'
exec sp_rename 't_mem_member','t_mem_member_006'
exec sp_rename 'T_BUS_VC','T_BUS_VC_006'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_006'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_006'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_006'
exec sp_rename 't_mem_member','t_mem_member_013'
exec sp_rename 'T_BUS_VC','T_BUS_VC_013'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_013'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_013'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_013'
exec sp_rename 't_mem_member','t_mem_member_009'
exec sp_rename 'T_BUS_VC','T_BUS_VC_009'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_009'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_009'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_009'
exec sp_rename 't_mem_member','t_mem_member_011'
exec sp_rename 'T_BUS_VC','T_BUS_VC_011'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_011'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_011'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_011'
exec sp_rename 't_mem_member','t_mem_member_007'
exec sp_rename 'T_BUS_VC','T_BUS_VC_007'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_007'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_007'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_007'
exec sp_rename 't_mem_member','t_mem_member_008'
exec sp_rename 'T_BUS_VC','T_BUS_VC_008'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_008'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_008'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_008'
exec sp_rename 't_mem_member','t_mem_member_010'
exec sp_rename 'T_BUS_VC','T_BUS_VC_010'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_010'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_010'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_010'
exec sp_rename 't_mem_member','t_mem_member_012'
exec sp_rename 'T_BUS_VC','T_BUS_VC_012'
exec sp_rename 'T_BUS_CONSUME_REC','T_BUS_CONSUME_REC_012'
exec sp_rename 'T_BUS_VC_TPL','T_BUS_VC_TPL_012'
exec sp_rename 'T_SYS_CARD_TYPE','T_BUS_VC_TPL_012'
SELECT * FROM T_BUS_CONSUME_REC_008
SELECT * FROM T_BUS_VC_TPL_010
SELECT * FROM t_mem_member_010
SELECT * FROM T_BUS_VC_010
select count(*) from T_BUS_CONSUME_REC
SELECT * FROM TCompany
drop table T_BUS_CONSUME_REC
delete t_mem_member where member_name = '' and member_code = ''
SELECT * FROM t_mem_member
SELECT 'SELECT * FROM ' + name FROM sysobjects where name like 'T_%'
ORDER BY name
SELECT 'SELECT * FROM ' + name FROM sysobjects where name like 'TImp%'
ORDER BY name
SELECT 'drop table ' + name FROM sysobjects where name like 'T_%'
ORDER BY name
UPDATE TMemberCardType SET FAllowRchg = 1,FAllowSale = 1
select sum(cast(remain_value as float)) from T_BUS_VC_003
SELECT * FROM T_BUS_VC_003
SELECT * FROM T_BUS_VC_TPL_001
SELECT * FROM T_BUS_VC_TPL_002
SELECT * FROM T_BUS_VC_TPL_003
SELECT * FROM TMemberCard
WHERE FExpiredDate < '2018-04-01'
UPDATE TMemberCard SET FExpiredDate = '9000-01-01'
UPDATE TMemberCardType SET FValidityPeriod = 100
SELECT * FROM TCompany
--<EFBFBD>ŵ<EFBFBD>
SELECT * FROM TCompany
ALTER TABLE TCompany ADD FStoreId VARCHAR(100)
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_001) WHERE FNo = '001'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_002) WHERE FNo = '002'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_003) WHERE FNo = '003'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_004) WHERE FNo = '004'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_005) WHERE FNo = '005'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_006) WHERE FNo = '006'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_013) WHERE FNo = '013'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_009) WHERE FNo = '009'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_011) WHERE FNo = '011'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_007) WHERE FNo = '007'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_008) WHERE FNo = '008'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_010) WHERE FNo = '010'
UPDATE TCompany SET FStoreId = (SELECT DISTINCT store_id FROM T_BUS_VC_TPL_012) WHERE FNo = '012'
DROP TABLE TImpCardType
CREATE TABLE TImpCardType
(
FId BIGINT,
FNo VARCHAR(20),
FName VARCHAR(100),
FPrice VARCHAR(100),
FType VARCHAR(100),
FStoreId VARCHAR(100),
FValueType INT
)
CREATE TABLE TImpItem
(
FItemId BIGINT,
FCourseId BIGINT,
FItemNo VARCHAR(100),
FItemName VARCHAR(100)
)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_001
UNION ALL
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_002
UNION ALL
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_003
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_004
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_005
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_006
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_013
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_007
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_009
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_011
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_008
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_010
WHERE card_type != 1
INSERT TImpCardType(FNo,FName,FId,Fprice,FType,FStoreId)
SELECT 'L' + store_id + tpl_id, name,store_id + tpl_id,price,card_type,store_id FROM T_BUS_VC_TPL_012
WHERE card_type != 1
UPDATE TImpCardType SET FValueType = 1
UPDATE TImpCardType SET FValueType = 3 WHERE FType = 1
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 ,FNo,FName,FValueType,2 AS FMaterial,FPrice,0 AS FCardFeeAmt,3 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 FMinRchgAmt,0 AS FSalePointMode,0 AS FSalePointValue,0 AS FRchgPointMode,0 AS FRchgPointValue,0 AS FPaySmsFee,0 AS FTimeCard,100 AS FValidityPeriod,1 AS FValidityPeriodUnit,NULL AS FExpiredDate,'' AS FDefaultMemo,GETDATE()FCreateTime,1 AS FAllowSale,1 AS FAllowRchg,0 AS FDeptId,1 AS FEnabled,0 AS FOrder
FROM TImpCardType
ORDER BY FNo
UPDATE TMemberCardType SET FEnabled = 1,FAllowsale = 1,FAllowRchg = 1,FValidityPeriod = 100,FValidityPeriodUnit = 1,FExpiredDate = null
WHERE FId IN(SELECT FId FROM TImpCardType)
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
SELECT dbo.FNNewId(),C.FId,I.FId,1,1,1
FROM TImpCardType AS I,TCompany AS C
WHERE I.FId > 1
AND (C.FStoreId = I.FStoreId or C.FId = 1)
INSERT TImpItem(FItemId,FCourseId,FItemNo,FItemName)
SELECT dbo.FNNewId(), store_id + tpl_id,'L' + store_id + tpl_id,name
FROM T_BUS_VC_TPL_012
WHERE card_type = 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,FDisplay)
SELECT FItemId,FItemNo,FItemNo,FItemName,FItemName,0,dbo.FNGetFirstPinYin(FItemName),'',1,1,1,'','','',1,0,0,0,0,1,0,0,1,1
FROM TImpItem
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 I.FId IN(SELECT FItemId FROM TImpItem)
AND C.FNo IN('012','001')
INSERT TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FCourseId,
FItemNo + 'L1',
FItemName ,
dbo.FNGetFirstPinyin(FItemName) AS FBriefCode,
FItemId AS FItemId,
0 AS FPackId,
1 AS FSequence,
0 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
SELECT * FROM T_BUS_VC_003 WHERE store_id!= (SELECT FStoreId FROM TCompany WHERE FNo = '003')
SELECT * FROM t_mem_member_003 WHERE store_id != (SELECT FStoreId FROM TCompany WHERE FNo = '003')
SELECT * FROM T_BUS_VC_002 WHERE store_id!= (SELECT FStoreId FROM TCompany WHERE FNo = '002')
SELECT * FROM t_mem_member_002 WHERE store_id != (SELECT FStoreId FROM TCompany WHERE FNo = '002')
SELECT * FROM T_BUS_VC_001 WHERE store_id!= (SELECT FStoreId FROM TCompany WHERE FNo = '001')
SELECT * FROM t_mem_member_001 WHERE store_id != (SELECT FStoreId FROM TCompany WHERE FNo = '001')
SELECT * FROM T_BUS_VC_005 WHERE store_id!= (SELECT FStoreId FROM TCompany WHERE FNo = '005')
UPDATE t_mem_member_001 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '001')
UPDATE t_mem_member_002 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '002')
UPDATE t_mem_member_003 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '003')
UPDATE t_mem_member_004 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '004')
UPDATE t_mem_member_005 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '005')
UPDATE t_mem_member_006 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '006')
UPDATE t_mem_member_013 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '013')
UPDATE t_mem_member_007 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '007')
UPDATE t_mem_member_009 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '009')
UPDATE t_mem_member_011 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '011')
UPDATE t_mem_member_008 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '008')
UPDATE t_mem_member_010 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '010')
UPDATE t_mem_member_012 SET store_id = (SELECT FStoreId FROM TCompany WHERE FNo = '012')
DECLARE @SQL VARCHAR(MAX)
SELECT @SQL = ''
SELECT @SQL = @SQL + name + ',' FROM syscolumns WHERE id = object_id('T_BUS_CONSUME_REC_001') ORDER BY name
PRINT @SQL
DECLARE @SQL VARCHAR(MAX)
SELECT @SQL = ''
SELECT @SQL = @SQL + name + ',' FROM syscolumns WHERE id = object_id('T_BUS_VC_001') ORDER BY name
PRINT @SQL
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_001
UNION ALL
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
FROM t_mem_member_002
UNION ALL
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
FROM t_mem_member_003
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_004
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_005
select * from TImpMember
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_006
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_013
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_007
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_009
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_011
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_008
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_010
SELECT address,birthday,cash,create_by,create_date,email,expense,gender,identity_no,image_id,is_cost,job,level_id,level_name,mark_for_delete,member_code,member_id,member_name,member_no,member_password,mobile,open_time,opt_counter,phone_tel,remain_available_value,remain_charged_value,remain_debt_value,remain_point,remark,return_expense,status,store_id,total_charged_value,total_debt_value,total_point,update_by,update_date,zipcode
INTO TImpMember
FROM t_mem_member_012
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_001
UNION ALL
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
FROM T_BUS_VC_002
UNION ALL
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
FROM T_BUS_VC_003
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_004
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_005
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_006
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_013
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_007
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_009
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_011
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_008
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_010
SELECT accum_charged_value,average_cost,card_id,card_no,create_by,create_date,debt_value,end_time,first_staff_id,first_time,last_staff_id,last_time,mark_for_delete,member_id,name,opt_counter,remain_num,remain_value,status,store_id,tpl_id,update_by,update_date
INTO TImpMemberCard
FROM T_BUS_VC_012
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_001
UNION ALL
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
FROM T_BUS_CONSUME_REC_002
UNION ALL
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
FROM T_BUS_CONSUME_REC_003
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_004
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_005
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_006
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_013
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_007
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_009
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_011
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_008
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_010
SELECT bill_id,cash,cash_staff_id,commision_cash,consume_date,consume_id,consume_no,consume_pdt_name,consume_pdt_num,create_by,create_date,customer_type,donate_cash,donate_num,donate_rollback,invalidate__date,invalidate_reason,invalidate_remark,invalidate_staff_id,is_commit,is_donate,is_free,is_invalidate,is_message,is_pause,is_photo,mark_for_delete,member_id,number,operate__date,opt_counter,payment_rollback,product_rollback,project_id,project_name,project_type,queue_no,real_cash,remark,service_staff,store_id,update_by,update_date
INTO TImpMemberTransHist
FROM T_BUS_CONSUME_REC_012
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember ADD FName VARCHAR(50)
ALTER TABLE TImpMember ADD FGender INT
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember ADD FCreateDate DATETIME
ALTER TABLE TImpMember ADD FCompId BIGINT
ALTER TABLE TImpMember ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
ALTER TABLE TImpMember ADD FBirthday DATETIME
ALTER TABLE TImpMember ADD FBirthdayType CHAR
ALTER TABLE TImpMember ADD FCustom1 VARCHAR(100)
ALTER TABLE TImpMember ADD FPointText VARCHAR(100)
ALTER TABLE TImpMember ADD FDeleted BIT
ALTER TABLE TImpMemberCard ADD FMemId BIGINT
ALTER TABLE TImpMemberCard ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT
ALTER TABLE TImpMemberCard ADD FCourseId BIGINT
ALTER TABLE TImpMemberCard ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FBalance2 DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FRemainTimes INT
ALTER TABLE TImpMemberCard ADD FPurTimes INT
ALTER TABLE TImpMemberCard ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FItemId BIGINT
ALTER TABLE TImpMemberCard ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCard ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberCard ADD FCompId BIGINT
ALTER TABLE TImpMemberCard ADD FCardId BIGINT
ALTER TABLE TImpMemberCard ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMemberCard ADD FDeleted BIT
UPDATE TImpMember SET FDeleted = 0
UPDATE TImpMember SET FDeleted = 1 WHERE status != '0'
--<EFBFBD><EFBFBD>Ա<EFBFBD>ŵ<EFBFBD>
SELECT * FROM TImpMember WHERE status != '0'
SELECT * FROM TImpMember
WHERE member_no
IN(
SELECT member_no
FROM TImpMember
WHERE status = '0'
GROUP BY member_no
HAVING(SUM(1) > 1)
)AND status = '0'
ALTER TABLE TCompany ADD FPrefix VARCHAR
UPDATE TCompany SET FPrefix = 'A' WHERE FNo = '001'
UPDATE TCompany SET FPrefix = 'B' WHERE FNo = '002'
UPDATE TCompany SET FPrefix = 'C' WHERE FNo = '003'
UPDATE TCompany SET FPrefix = 'D' WHERE FNo = '004'
UPDATE TCompany SET FPrefix = 'E' WHERE FNo = '005'
UPDATE TCompany SET FPrefix = 'F' WHERE FNo = '006'
UPDATE TCompany SET FPrefix = 'G' WHERE FNo = '007'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FMemNo = member_no
UPDATE A SET A.FMemNo = B.FPrefix + A.member_no
FROM TImpMember AS A,TCompany AS B
WHERE A.store_id = B.FStoreId
and A.FDeleted = 0
AND A.FMemNo IN(SELECT FCardNo FROM TMemberCard)
SELECT * FROM TMemberCard WHERE FCardNo = '7716'
SELECT * FROM TMember WHERE FMemId = 16642831
SELECT * FROM TMemberCard WHERE FMemId = 16642831
delete TMember WHERE FMemId IN(SELECT FMemId FROM TImpMEMBER)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FMemNo = (SELECT FPrefix FROM TCompany WHERE TCompany.FId = TImpMember.FCompId) + member_no
WHERE member_no
IN(
SELECT member_no
FROM TImpMember
WHERE status = '0'
GROUP BY member_no
HAVING(SUM(1) > 1)
)AND status = '0'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>
ALTER TABLE TImpMember ADD FSeq INT IDENTITY
ALTER TABLE TImpMember ADD FIndex INT
UPDATE A
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMember AS B WHERE A.FMemNo = B.FMemNo AND (A.open_time > B.open_time OR (A.open_time = B.open_time AND (A.FSeq > B.FSeq) )))
FROM TImpMember AS A
drop table #Member
SELECT FMemNo
INTO #Member
FROM TImpMember
WHERE status = '0'
GROUP BY FMemNo
HAVING(SUM(1) > 1)
UPDATE TImpMember SET FMemNo = FMemNo + 'A' WHERE FMemNo IN(SELECT FMemNo FROM #Member) AND FIndex = 1
UPDATE TImpMember SET FMemNo = FMemNo + 'B' WHERE FMemNo IN(SELECT FMemNo FROM #Member) AND FIndex = 2
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FName = member_name
--<EFBFBD>
UPDATE TImpMember SET FMobile = mobile
--<EFBFBD>Ա<EFBFBD>
UPDATE TImpMember SET FGender = gender
--<EFBFBD><EFBFBD>ע
UPDATE TImpMember SET FMemo = remark
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FBirthdayType = 'G'
UPDATE TImpMember SET FBirthday = birthday WHERE LEFT(birthday,10) != '1990-01-01'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FCreateDate = open_time
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FPoint = remain_point
--<EFBFBD><EFBFBD>ԱID
UPDATE TImpMember SET FMemId = store_id + member_id
--<EFBFBD><EFBFBD>Ա<EFBFBD>ŵ<EFBFBD>
UPDATE TImpMember SET FCompId = (SELECT FId FROM TCompany AS B WHERE B.FStoreId = TImpMember.store_id)
--<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>
UPDATE TImpMemberCard SET FCompId = (SELECT FId FROM TCompany AS B WHERE B.FStoreId = TImpMemberCard.store_id)
--״̬
UPDATE TImpMemberCard SET FDeleted = 0
UPDATE TImpMemberCard SET FDeleted = 1 WHERE status != '0'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FCardTypeId = B.FId
FROM TIMpMemberCard AS A,TImpCardType AS B
WHERE A.store_id + A.tpl_id = B.FId
--<EFBFBD>Ƴ<EFBFBD>
UPDATE A
SET A.FCourseId = B.FCourseId
FROM TIMpMemberCard AS A,TImpItem AS B
WHERE A.store_id + A.tpl_id = B.FCourseId
--<EFBFBD><EFBFBD>ԱId
UPDATE TImpMemberCard SET FMemId = store_id + member_id
--<EFBFBD><EFBFBD>Id
UPDATE TImpMemberCard SET FCardId = store_id + card_id
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberCard SET FCreateDate = CREATE_DATE
UPDATE TImpMemberCard SET FExpiredDate = '9000-01-01'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberCard SET FBalance = CAST(remain_value AS FLOAT)
UPDATE TImpMemberCard SET FRemainTimes = CAST(remain_num AS FLOAT)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FCardNo = B.FMemNo
FROM TImpMemberCard AS A,TImpMember AS B
WHERE A.FMemId = B.FMemId
ALTER TABLE TImpMemberCard ADD FSeq INT IDENTITY
ALTER TABLE TImpMemberCard ADD FIndex INT
UPDATE A
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMemberCard AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
FROM TImpMemberCard AS A
where ISNULL(FCardTypeId,0) != 0
AND FDeleted = 0
DROP TABLE #Card
SELECT FCardNo INTO #Card
FROM TImpMemberCard
where ISNULL(FCardTypeId,0) != 0
AND FDeleted = 0
GROUP BY FCardNo
HAVING(SUM(1) > 1)
UPDATE TImpMemberCard SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR) WHERE FCardNo IN(SELECT FCardNo FROM #Card)
AND ISNULL(FCardTypeId,0) != 0
AND FDeleted = 0
AND FIndex > 1
SELECT * FROM TCompany WHERE FId = 5134797411090089978
SELECT* FROM TImpMEMBER where FMemNo = '7716'
SELECT* FROM TMemberCard where FCardNo = '7716'
SELECT * FROM TImpMemberCard WHERE FCardNO IN(SELECT FCardNo FROM TMemberCard)
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),
0 AS FTypeId,
FCompId AS FCompId,
ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate,
FGender AS FGender,
FBirthdayType AS FBirthdayType,
FBirthday AS FBirthday,
'' AS FTelephone,
ISNULL(FMobile,'') AS FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
'' AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
ISNULL( FPoint,0) AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
ISNULL(FMemo,'') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
WHERE FDeleted = 0
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FCardNo AS FNo,
FCardNo AS FFaceNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
1 AS FState,
FCreateDate AS FCreateDate,
FExpiredDate AS FExpiredDate,
ISNULL(FRemainTimes,0) AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(FMemo,'') AS FMemo
FROM TImpMemberCard
WHERE FDeleted = 0
AND FMemId IN(SELECT FMemId FROM TMember)
AND FCardTypeId IS NOT NULL
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL AS FExpiredDate,''
FROM TImpMemberCard AS A
WHERE FDeleted = 0
AND FMemId IN(SELECT FMemId FROM TMember)
AND FCardTypeId IS NOT NULL
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.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMemberCard AS A
WHERE FDeleted = 0
AND FMemId IN(SELECT FMemId FROM TMember)
AND FCardTypeId IS NOT NULL
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 TMember AS A WHERE FPoint != 0
AND FMemId IN(SELECT FMemId FROM TImpMember)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
SELECT * FROM TImpMemberTransHist
ALTER TABLE TImpMemberTransHist ADD FMemId BIGINT
ALTER TABLE TImpMemberTransHist ADD FCompId BIGINT
UPDATE TImpMemberTransHist SET FMemId = store_id + member_id
UPDATE TImpMemberTransHist SET FCompId = (SELECT FId FROM TCompany WHERE TCompany.FStoreId = TImpMemberTransHist.store_id)
SELECT * FROM TImpMemberTransHist WHERE FCompId IS NULL
select * from TImpMemberTransHist
SELECT * FROM TImpMember
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT DBO.FNNewId(),A.FMemId,A.consume_date,0,ISNULL(A.FCompId,0),'DR','Import',consume_no,project_name,real_cash,1,real_cash,'',service_staff,remark
FROM TImpMemberTransHist AS A
WHERE ISNULL(FMemId,0) != 0
AND FMemId IN(SELECT FMemId FROM TImpMember)
USE BEIJING_PSTYLE
SELECT
(SELECT CAST(CAST(MAX(FRowVersion) AS BIGINT) AS VARCHAR) FROM TItem)
+ '_' +
(SELECT CAST(p.rows AS VARCHAR)
FROM sys.indexes i, sys.partitions p
WHERE i.object_id = object_id('TGoods')
AND p.object_id = i.object_id
AND is_primary_key = 1
AND p.index_id = i.index_id)
SELECT * FROM TItem
use beijing_pstyle
SELECT * FROM TMemberCard WHERE FValueTYpe = 3
AND FCardId IN(SELECT FCardId FROM TConsumeItemPayment)
SELECT * FROM TMemberCardType WHERE FValueType = 3
SELECT * FROM TMemberPointHist WHERE FMemId IN(SELECT FMemId FROM TIMpMember_008)
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT A.FCardId,A.FMemId,A.FCourseId,0,I.FItemId,A.FCompId,A.FRemainTimes,0,A.FBalance,0,0,A.FCreateDate,A.FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,CASE WHEN FBalance = 0 OR FRemainTimes = 0 THEN 0 ELSE FBalance / FRemainTimes END
FROM TImpMemberCard AS A ,TImpItem AS I
WHERE A.FCourseId = I.FCourseId
AND A.FMemId IN(SELECT FMemId FROM TMember)
SELECT * FROM TImpMember WHERE FMemId = 1716582
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime)
SELECT dbo.FNNewId(),A.FMemId,A.FCardId AS FCardId,0, ISNULL(A.FCourseId,0),getdate(),FRemainTimes,0,0,0,FCompId,'DR','Import',0,'',0,getdate()
FROM TImpMemberCard AS A ,TImpItem AS I
WHERE A.FCourseId = I.FCourseId
AND A.FMemId IN(SELECT FMemId FROM TMember)
SELECT * FROM TMemberCard WHERE FCompId = dbo.FNCompId('008')
SELECT * FROM sysobjects WHERE name LIKE 'Timp%'
exec sp_rename 'TImpCardType','TImpCardType_123'
exec sp_rename 'TImpItem','TImpItem_123'
exec sp_rename 'TImpMember','TImpMember_123'
exec sp_rename 'TImpMemberCard','TImpMemberCard_123'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_123'
exec sp_rename 'TImpCardType','TImpCardType_004'
exec sp_rename 'TImpItem','TImpItem_004'
exec sp_rename 'TImpMember','TImpMember_004'
exec sp_rename 'TImpMemberCard','TImpMemberCard_004'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_004'
exec sp_rename 'TImpCardType','TImpCardType_005'
exec sp_rename 'TImpItem','TImpItem_005'
exec sp_rename 'TImpMember','TImpMember_005'
exec sp_rename 'TImpMemberCard','TImpMemberCard_005'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_005'
exec sp_rename 'TImpCardType','TImpCardType_006'
exec sp_rename 'TImpItem','TImpItem_006'
exec sp_rename 'TImpMember','TImpMember_006'
exec sp_rename 'TImpMemberCard','TImpMemberCard_006'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_006'
exec sp_rename 'TImpCardType','TImpCardType_013'
exec sp_rename 'TImpItem','TImpItem_013'
exec sp_rename 'TImpMember','TImpMember_013'
exec sp_rename 'TImpMemberCard','TImpMemberCard_013'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_013'
exec sp_rename 'TImpCardType','TImpCardType_007'
exec sp_rename 'TImpItem','TImpItem_007'
exec sp_rename 'TImpMember','TImpMember_007'
exec sp_rename 'TImpMemberCard','TImpMemberCard_007'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_007'
exec sp_rename 'TImpCardType','TImpCardType_009'
exec sp_rename 'TImpItem','TImpItem_009'
exec sp_rename 'TImpMember','TImpMember_009'
exec sp_rename 'TImpMemberCard','TImpMemberCard_009'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_009'
exec sp_rename 'TImpCardType','TImpCardType_011'
exec sp_rename 'TImpItem','TImpItem_011'
exec sp_rename 'TImpMember','TImpMember_011'
exec sp_rename 'TImpMemberCard','TImpMemberCard_011'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_011'
exec sp_rename 'TImpCardType','TImpCardType_008'
exec sp_rename 'TImpItem','TImpItem_008'
exec sp_rename 'TImpMember','TImpMember_008'
exec sp_rename 'TImpMemberCard','TImpMemberCard_008'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_008'
exec sp_rename 'TImpCardType','TImpCardType_010'
exec sp_rename 'TImpItem','TImpItem_010'
exec sp_rename 'TImpMember','TImpMember_010'
exec sp_rename 'TImpMemberCard','TImpMemberCard_010'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_010'
exec sp_rename 'TImpCardType','TImpCardType_012'
exec sp_rename 'TImpItem','TImpItem_012'
exec sp_rename 'TImpMember','TImpMember_012'
exec sp_rename 'TImpMemberCard','TImpMemberCard_012'
exec sp_rename 'TImpMemberTransHist','TImpMemberTransHist_012'