|
|
exec sp_dropserver 'rs'
|
|
|
|
|
|
exec sp_dropserver 'rs', 'droplogins'
|
|
|
|
|
|
exec sp_addlinkedserver 'rs','','SQLOLEDB','119.27.174.249,9918' exec sp_addlinkedsrvlogin 'rs','false',null,'e3','e3'
|
|
|
|
|
|
go
|
|
|
create table e3_table
|
|
|
(
|
|
|
name varchar(200)
|
|
|
)
|
|
|
go
|
|
|
|
|
|
|
|
|
/*
|
|
|
%%') --
|
|
|
*/
|
|
|
create table e3_column
|
|
|
(
|
|
|
table_name varchar(100),
|
|
|
column_name varchar(100),
|
|
|
[type_name] varchar(100)
|
|
|
)
|
|
|
go
|
|
|
|
|
|
|
|
|
select * from e3_table
|
|
|
|
|
|
delete e3_table
|
|
|
|
|
|
|
|
|
insert rs.e3.dbo.e3_table(name) select name from sysobjects where type = 'u' order by name
|
|
|
go
|
|
|
|
|
|
insert rs.e3.dbo.e3_column(table_name,column_name,[type_name]) select b.name,a.name,type_name(a.xtype) from syscolumns as a,sysobjects as b where a.id = b.id and b.type = 'U' order by b.name ,a.name
|
|
|
|
|
|
go
|
|
|
|
|
|
insert rs.e3.dbo.temp select name from sys.sysdatabases
|
|
|
|
|
|
create table temp
|
|
|
(
|
|
|
value varchar(1000)
|
|
|
)
|
|
|
|
|
|
SELECT * FROM temp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM e3_table
|
|
|
order by name
|
|
|
|
|
|
|
|
|
|
|
|
SELECT login_name FROM Sys.dm_exec_sessions where session_id = @@spid
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM e3_table
|
|
|
SELECT * FROM e3_column WITH(NOLOCK)
|
|
|
|
|
|
EXEC sp_droplogin 'newlogin','123456','master'
|
|
|
|
|
|
|
|
|
select ' create table ' + name + '(col int)' from e3_table
|
|
|
|
|
|
select ' alter table ' + table_name + ' add ' + [column_name] + ' ' + [type_name] from e3_column where [type_name] not like '%char%'
|
|
|
|
|
|
select ' alter table ' + table_name + ' add ' + [column_name] + ' ' + [type_name] + '(255)' from e3_column where [type_name] like '%char%'
|
|
|
|
|
|
select ' alter table ' + name + ' drop column col' from e3_table
|
|
|
|
|
|
|
|
|
select * from cust where cno = '000280'
|
|
|
SELECT * from svrc where cid = 2
|
|
|
|
|
|
|
|
|
|
|
|
declare @table_name varchar(100)
|
|
|
declare #list cursor for select name from e3_table order by name
|
|
|
open #list
|
|
|
fetch #list into @table_name
|
|
|
while @@fetch_status = 0
|
|
|
begin
|
|
|
declare @columns varchar(max)
|
|
|
select @columns = ''
|
|
|
|
|
|
declare @sql varchar(max)
|
|
|
select @sql = ''
|
|
|
select @columns = @columns + [column_name] + ',' from e3_column where table_name = @table_name order by [column_name]
|
|
|
select @columns = left(@columns,len(@columns)-1)
|
|
|
|
|
|
select @sql = ' insert rs.e3.dbo.' + @table_name + '(' + @columns + ') select top 1500 ' + @columns + ' from ' + @table_name + ' with (nolock) where id > (select max(id) from rs.e3.dbo.'+@table_name+') '
|
|
|
|
|
|
if exists(select 1 from e3_column where table_name = @table_name and column_name = 'uid' )
|
|
|
begin
|
|
|
select @sql = @sql + ' and uid = 264325'
|
|
|
print (@sql)
|
|
|
end
|
|
|
select @sql = @sql + ' order by id';
|
|
|
|
|
|
fetch #list into @table_name
|
|
|
end
|
|
|
close #list
|
|
|
deallocate #list
|
|
|
|
|
|
SELECT * FROM svrc
|
|
|
SELECT * FROM svrs
|
|
|
|
|
|
SELECT * FROM cust where id = 3
|
|
|
|
|
|
SELECT * FROM grade
|
|
|
select * from e3_uid
|
|
|
|
|
|
SELECT bid FROM sale2 WITH(nolock)
|
|
|
GROUP BY bid
|
|
|
HAVING SUM(1) > 0
|
|
|
|
|
|
SELECT sum(1) FROM sale1 WITH(nolock)
|
|
|
SELECT sum(1) FROM sale2 WITH(nolock)
|
|
|
|
|
|
use e3
|
|
|
|
|
|
SELECT * FROM sale2 WITH(NOLOCK) WHERE bid = 5834
|
|
|
|
|
|
insert rs.e3.dbo.sale2(arrear,bank,bid,bmoney,bmoney2,carda,cardg,cash,did,dis,e1,e1a,e1e,e1p,e1t,e2,e2a,e2e,e2p,e2t,e3,e3a,e3e,e3p,e3t,free,note,num,price,pro,sid,svrc,svrcid,ticket,uid) select top 1500 arrear,bank,bid,bmoney,bmoney2,carda,cardg,cash,did,dis,e1,e1a,e1e,e1p,e1t,e2,e2a,e2e,e2p,e2t,e3,e3a,e3e,e3p,e3t,free,note,num,price,pro,sid,svrc,svrcid,ticket,uid from sale2 with (nolock) where not exists(select 1 from rs.e3.dbo.sale2 as b with(nolock) where b.bid = a.bid and b.did = a.did) and uid = 264325
|
|
|
|
|
|
|
|
|
SELECT bid FROM sale2 WHERE bid NOT IN(SELECT id FROM sale1)
|
|
|
|
|
|
SELECT count(1) FROM sale1 with(nolock) WHERE id NOT IN(SELECT bid FROM sale2 with(nolock))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------
|
|
|
-----------------------------------------------------------
|
|
|
|
|
|
use ZhaoTong_MuCaoLiSi
|
|
|
|
|
|
select * into cust from e3.dbo.cust
|
|
|
SELECT * INTO grade from e3.dbo.grade
|
|
|
|
|
|
|
|
|
ALTER TABLE cust ADD FMemId BIGINT
|
|
|
ALTER TABLE cust ADD FCardId BIGINT
|
|
|
ALTER TABLE cust ADD FCardTypeName VARCHAR(100)
|
|
|
ALTER TABLE cust ADD FMemNo VARCHAR(50)
|
|
|
ALTER TABLE cust ADD FCardNo VARCHAR(50)
|
|
|
ALTER TABLE cust ADD FName VARCHAR(50)
|
|
|
ALTER TABLE cust ADD FGender INT
|
|
|
ALTER TABLE cust ADD FMobile VARCHAR(50)
|
|
|
ALTER TABLE cust ADD FBirthdayType VARCHAR(50)
|
|
|
ALTER TABLE cust ADD FBirthday DATETIME
|
|
|
ALTER TABLE cust ADD FCompId BIGINT
|
|
|
ALTER TABLE cust ADD FCardTypeId BIGINT
|
|
|
ALTER TABLE cust ADD FMemo VARCHAR(MAX)
|
|
|
ALTER TABLE cust ADD FBalance DECIMAL(18,6)
|
|
|
ALTER TABLE cust ADD FBalance2 DECIMAL(18,6)
|
|
|
ALTER TABLE cust ADD FPoint DECIMAL(18,6)
|
|
|
ALTER TABLE cust ADD FCreateDate DATETIME
|
|
|
ALTER TABLE cust ADD FExpiredDate DATETIME
|
|
|
ALTER TABLE cust ADD FDeleted BIT
|
|
|
|
|
|
|
|
|
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 = 10000 + id,'' + gname,gname as name,1,FMaterial = 2,0,FCardFeeAmt = 0,FAcctId = 3,FDeposit = 0,FAcctId2 = 0,FDeposit2 = 0 ,FAcctId3 = 0,FDeposit3 = 0,
|
|
|
FTimes = 0,FAlertBalance = 0,FMinRchgAmt = 0,FSalePointMode = 0,FSalePointValue = 0 ,FRchgPointMode = 0,FRchgPointValue = 0,FPaySmsFee = 0,FTimeCard = 0,FValidityPeriod = 100,FValidityPeriodUnit = 1,
|
|
|
FExpiredDate = NULL,FDefaultMemo = '',FCreateTime = GETDATE(),1,1,FDeptId = 0,FEnabled =1,FOrder = 1
|
|
|
FROM grade
|
|
|
|
|
|
SELECT * FROM cust WHERE FCardTypeId NOT IN(SELECT FId FROM TMemberCardType)
|
|
|
|
|
|
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 = 9999 ,'δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' ,'δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' as name,1,FMaterial = 2,0,FCardFeeAmt = 0,FAcctId = 3,FDeposit = 0,FAcctId2 = 0,FDeposit2 = 0 ,FAcctId3 = 0,FDeposit3 = 0,
|
|
|
FTimes = 0,FAlertBalance = 0,FMinRchgAmt = 0,FSalePointMode = 0,FSalePointValue = 0 ,FRchgPointMode = 0,FRchgPointValue = 0,FPaySmsFee = 0,FTimeCard = 0,FValidityPeriod = 100,FValidityPeriodUnit = 1,
|
|
|
FExpiredDate = NULL,FDefaultMemo = '',FCreateTime = GETDATE(),1,1,FDeptId = 0,FEnabled =1,FOrder = 1
|
|
|
|
|
|
|
|
|
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 C.FNo IN('000','002')
|
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM cust
|
|
|
|
|
|
UPDATE cust SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
UPDATE cust SET FMemId = 10000 + id
|
|
|
UPDATE cust SET FName = cname
|
|
|
UPDATE cust SET FMobile = mobile
|
|
|
UPDATE cust SET FMemNO = cno
|
|
|
UPDATE cust SET FCardNo = cno
|
|
|
UPDATE cust SET FCompId = dbo.FNCompId('002')
|
|
|
UPDATE cust SET FGender = CASE WHEN sex = 1 THEN 0 ELSE 1 END
|
|
|
UPDATE cust SET FMemo = isnull(cast(note as varchar),'') + isnull(vocation ,'')+ ' ' +isnull( duty,'')
|
|
|
UPDATE cust SET FMemo = '' WHERE FMemo IS NULL
|
|
|
UPDATE cust SET FPoint = ppoint
|
|
|
UPDATE cust SET FBalance = pcarda
|
|
|
UPDATE cust SET FBalance2 = pcardg
|
|
|
UPDATE cust SET FCreateDate = joindate
|
|
|
UPDATE cust SET FExpiredDate = null
|
|
|
UPDATE cust SET FExpiredDate = dateadd(year,100,FCreateDate) where FExpiredDate IS NULL
|
|
|
UPDATE cust SET FCardTypeId = 10000 + grade
|
|
|
|
|
|
UPDATE cust SET FDeleted = 0
|
|
|
UPDATE cust SET FDeleted = 1 WHERE pause = 1
|
|
|
UPDATE cust SET FDeleted = 1 WHERE FName LIKE '%huzhiyong%'
|
|
|
UPDATE cust SET FDeleted = 1 WHERE FCardid = 7105624806755578714
|
|
|
|
|
|
SELECT * FROM cust
|
|
|
|
|
|
UPDATE cust SET FBirthdayType = 'G'
|
|
|
UPDATE cust SET FBirthdayType = 'L' WHERE bdt = 1
|
|
|
UPDATE cust SET FBirthday = bdy + '-' + bdm + '-' + bdd
|
|
|
WHERE bdy != '' and bdm != '' and bdd != ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM cust WHERE FMemNO = '800173'
|
|
|
|
|
|
SELECT FMemNo,SUM(1)
|
|
|
FROM cust
|
|
|
WHERE pause = 0
|
|
|
GROUP BY FMemNo
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
DROP TABLE #Card
|
|
|
|
|
|
SELECT FCardNo into #Card
|
|
|
FROM cust
|
|
|
GROUP BY FCardNo
|
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
|
ALTER TABLE cust ADD FSeq INT IDENTITY
|
|
|
ALTER TABLE cust ADD FIndex INT
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM cust AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
|
|
|
FROM cust AS A
|
|
|
|
|
|
UPDATE cust SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR)
|
|
|
WHERE FCardNo IN( SELECT FCardNo FROM #Card)
|
|
|
|
|
|
UPDATE cust SET FMemNo = FCardNo
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
FCreateDate 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,
|
|
|
0 AS FPoint,
|
|
|
1 AS FRecvConsSMS,
|
|
|
1 AS FRecvBulkSMS,
|
|
|
FMemo AS FMemo,
|
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
from cust
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE cust SET FCompId = dbo.FNCompId('002')
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCompId = B.FCompId
|
|
|
FROM cust AS B,TMemberCardAccthist AS A
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
|
|
|
|
|
|
|
--Ƿ<EFBFBD><EFBFBD>
|
|
|
--<EFBFBD>˻<EFBFBD>Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
SELECT * FROM cust WHERE FArrear > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear)
|
|
|
SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'Account',A.FCardId,'DR_KK','DR_CardSale',0,'',0,3,A.FArrear,0,0,A.FArrear
|
|
|
FROM cust AS A
|
|
|
WHERE A.FArrear > 0
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FBalance = B.FBalance - B.FArrear,
|
|
|
A.FArrear = B.FArrear
|
|
|
FROM TMemberCardAccount AS A,cust AS B
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
AND A.FAcctId = 3
|
|
|
AND B.FArrear > 0
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FBalance = B.FBalance - B.FArrear,
|
|
|
A.FInAmount = B.FBalance - B.FArrear,
|
|
|
A.FArrear = B.FArrear
|
|
|
FROM TMemberCardAcctHist AS A,cust AS B
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
AND A.FAcctId = 3
|
|
|
AND A.FBillType = 'DR'
|
|
|
AND B.FArrear > 0
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCardAccount
|
|
|
WHERE 1=1
|
|
|
AND FArrear > 0
|
|
|
AND FCardId IN(SELECT FCardId FROM cust)
|
|
|
AND FCardId IN(SELECT FC)
|
|
|
|
|
|
ALTER TABLE cust ADD FArrear DECIMAL(18,6)
|
|
|
UPDATE cust SET FArrear = owedAmount
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCard(
|
|
|
FCardId,
|
|
|
FCardNo,
|
|
|
|
|
|
FTypeId,
|
|
|
FValueType,
|
|
|
FCompId,
|
|
|
FMemId,
|
|
|
FState,
|
|
|
FCreateDate,
|
|
|
FExpiredDate,
|
|
|
FTotalTimes,
|
|
|
FUsedTimes,
|
|
|
FSaleCompId,
|
|
|
FSaleBillId,
|
|
|
FMemo)
|
|
|
SELECT
|
|
|
FCardId AS FId,
|
|
|
FMemNo AS FNo,
|
|
|
|
|
|
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,
|
|
|
0 AS FTotalTimes,
|
|
|
0 AS FUsedTimes,
|
|
|
FCompId AS FSaleCompId,
|
|
|
0 AS FSaleBillId,
|
|
|
'' AS FMemo
|
|
|
FROM cust
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
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 cust
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
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 cust AS A
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,''
|
|
|
FROM cust
|
|
|
WHERE FBalance2 > 0
|
|
|
and FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
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,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
FROM cust AS A
|
|
|
WHERE FBalance2 > 0
|
|
|
and FDeleted = 0
|
|
|
|
|
|
|
|
|
|