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/明个/SQLQuery5.sql

256 lines
7.2 KiB

DELETE TMemb
SELECT * FROM TMemberSaleBill
DELETE TMemberCard
PDeleteMemberSaleBill
SELECT * INTO hyxx FROM laiwu_mingge_meiping..hyxx
SELECT * INTO hyxf FROM laiwu_mingge_meiping..hyxf
SELECT * INTO hykxx FROM laiwu_mingge_meiping..hykxx
delete hyxx WHERE hyxm = 'É¢¿Í'
delete TMember WHERE FMemNO = '00000'
SELECT * FROM hyxx WHERE hykmc = 'ÆÕͨ»áÔ±'
SELECT * FROM hyxf
ALTER TABLE hyxx ADD FMemId BIGINT
ALTER TABLE hyxx ADD FCardId BIGINT
UPDATE hyxx SET FMemId = dbo.FNNewId()
UPDATE hyxx SET FCardId = dbo.FNNewId()
SELECT hykmc FROM hyxx GROUP BY hykmc
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 1000 + id ,id,hykmc,1,2,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
FROM hykxx
WHERE id = 62
ORDER BY id
UPDATE TMemberCardType SET FAllowSale = 1,FAllowRchg = 1 ,FEnabled =1,FExpiredDate = NULl
SELECT * FROM TMemberCardType WHERE FId > 6
DELETE TMemberCardType WHERE FId > 6
DELETE TBasicDataChanges
UPDATE TMemberCardType SET FDeleted = 0 WHERE FId > 6
SELECT * FROM TCompany WHERE FId = 4734511574699135191
SELECT * FROM hyxx
UPDATE hyxx
SET hykh = 'A' + hykh
SET hykh = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(hykh,'£»',''),'£¿',''),'?',''),';',''),' ',''),'£º',''),'A','')
drop table hyxx
SELECT hykh,sum(1)
FROM hyxx
group by hykh
order by sum(1) desc
SELECT * FROM hyxx WHERE hykh = '801218'
UPDATE TMemberOldTransHist SET FCompId = 1
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 FId,
hybh AS FNo,
hyxm AS FName,
isnull(jm,'') AS FBriefCode,
0 AS FTypeId,
dbo.FNCompId('001') AS FCompId,
isnull(jrrq,getdate()) AS FCreateDate,
case xb when 'ÄÐ' then 1 else 0 end AS FGender,
'G' AS FBirthdayType,
null AS FBirthday,
case when len(dbo.FNTODBC(lxdh)) = 23 then right(dbo.FNTODBC(lxdh),11) else '' end AS FTelephone,
case when len(dbo.FNTODBC(lxdh)) = 23 then left(dbo.FNTODBC(lxdh),11) else lxdh end AS FTelephone,
'' 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,
'' AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from hyxx
where lxdh = '13806342699 15263486806'
select lxdh from hyxx
order by len(lxdh) desc
SELECT LEN('15020894144 13181763777')
ALTER TABLE TMember ALTER COLUMN FMobilePhone VARCHAR(30)
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
hybh AS FNo,
(SELECT FId FROM TMemberCardType WHERE FName = hykmc) AS FTypeId,
1 AS FValueType,
dbo.FNCompId('001') AS FCompId,
FMemId AS FMemId,
1 AS FState,
isnull( jrrq,getdate()) AS FCreateDate,
dateadd(yy,100, isnull( jrrq,getdate())) AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
0 AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(bz + char(10) + address,'') AS FMemo
FROM hyxx
SELECT * FROM hyxx WHERE hykmc NOT IN(SELECT FName FROM TMemberCardType)
SELECT * FROM TMemberCardType WHERE FNo = '62'
SELECT * FROM hyxx
INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT dbo.FNNewId(),FMEMID,FCardId AS FCardId,3,knje,knje,0,isnull(jrrq,getdate()),NULL,''
FROM hyxx
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
select dbo.FNNewId(),C.FMemId,A.FCardId,A.FAcctId,getdate(),C.FTypeId,C.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),''
from TMemberCardAccount AS A,TMemberCard AS C,hyxx AS D
where C.FCardId = A.FCardId
AND C.FCardId = D.FCardId
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT dbo.FNNewId(),A.FMemId,rq,A.FCardId,A.FCompId,'DR','Import','','',cast(xfje as decimal(18,6)),1,cast(xfje as decimal(18,6)),'','',''
FROM hyxf,TMemberCard AS A
WHERE A.FCardNo = hybh
SELECT * FROM hyxf
select * from xfxx2
update xfxx2 set hykh = 'A' + hykh
Truncate table TMemberOldTransHist
select * from xfxx
SELECT * FROM TMemberOld
select dateadd(yy,100,getdate())
UPDATE TMemberCard SET FExpiredDate = dateadd(yy,100,FCreateDate)
insert gcm12
(gcn00c,gcn01c,gcn02c,gcn09f,gcn10i,gcn12d,gcn13d,gcn15c,gcn17c,gcn22i,gcn24i,gcn04c,gcn06i,gcn03c,gcn16f)
select
'003',hykh,'0',knje,'0',jrrq,'22000101',hykh,'003','1','1',yddh,xb,hyxm,hyjf
from gcm12_01
UPDATE TMemberCard SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003')
UPDATE TMember SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003')
UPDATE TMemberCardAcctHist SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003')
SELECT * FROM TMemberSaleDetailPayment
SELECT FId,FNo INTO #Member FROM TMember WHERE FNo LIKE 'A%'
AND FCompId = 4734511574699135191
SELECT * FROM #Member
UPDATE #Member SET FNo = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(FNo,'£»',''),'£¿',''),'?',''),';',''),' ',''),'£º',''),'','')
UPDATE #Member SET FNo = REPLACE(FNo,'A','') WHERE FNo LIKE 'A%'
UPDATE #Member SET FNo = 'A' + FNo
WHERE FNo IN (SELECT FNo FROM TMember WHERE FCompId != 4734511574699135191)
SELECT * FROM #Member WHERE FNo like 'A%'
UPDATE B
SET B.FNo = 'A' + B.FNo
FROM #Member AS B,
(
SELECT FNo, COUNT(1) as cnt,max(FId) as FId FROM #Member
GROUP BY FNo
) AS A
WHERE cnt > 1
AND B.FId = A.FId
UPDATE A
SET A.FNo = B.FNo
FROM TMember AS A,#Member AS B
WHERE A.FId = B.FId
SELECT * FROM TMember WHERE FNo like 'A%'
UPDATE A
SET A.FNo = B.FNo,
A.FFaceNo = B.FNo
FROM TMemberCard AS A,TMember AS B
WHERE A.FId = B.FId
AND B.FCompId = 4734511574699135191
SELECT * FROM TMemberCard WHERE FNo like '%801127%'
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
SELECT dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled
FROM TMemberCardType AS I,TCompany AS C
WHERE I.FId > 6
AND C.FId != 0