|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
mysql使用内部操作字符集gbk来进行操作,即执行"SELECT*FROMtestWHEREname=xxxor1=1/*LIMIT1";从而注入成功server|剧本|数据利用SQLServer2000自带的“天生SQL剧本”工具,能够天生创立表、视图、存储历程等的SQL剧本。那末,可否将表中的数据也天生为SQL剧本,在查询剖析器中实行这些剧本后主动将数据导进到SQLServer中呢?谜底是一定的。上面的存储历程是一名高人写的,这位高人的姓氏已无人晓得,但SQLServer社区中偶然还可看到此不朽之作。CREATEPROCEDUREdbo.OutputData
@tablenamesysname
AS
declare@columnvarchar(1000)
declare@columndatavarchar(1000)
declare@sqlvarchar(4000)
declare@xtypetinyint
declare@namesysname
declare@objectIdint
declare@objectnamesysname
declare@identint
setnocounton
set@objectId=object_id(@tablename)
if@objectIdisnull--判别工具是不是存在
begin
print@tablename+工具不存在
return
endset@objectname=rtrim(object_name(@objectId))
if@objectnameisnullorcharindex(@objectname,@tablename)=0
begin
print@tablename+工具不在以后数据库中
return
endifOBJECTPROPERTY(@objectId,IsTable)1--判别工具是不是是表
begin
print@tablename+工具不是表
return
endselect@ident=status&0x80fromsyscolumnswhereid=@objectidandstatus&0x80=0x80if@identisnotnull
printSETIDENTITY_INSERT+@TableName+ON--界说游标,轮回取数据并天生Insert语句
declaresyscolumns_cursorcursorfor
selectc.name,c.xtypefromsyscolumnsc
wherec.id=@objectid
orderbyc.colid--翻开游标
opensyscolumns_cursor
set@column=
set@columndata=
fetchnextfromsyscolumns_cursorinto@name,@xtype
while@@fetch_status-1
begin
if@@fetch_status-2
begin
if@xtypenotin(189,34,35,99,98)--timestamp不需处置,image,text,ntext,sql_variant临时不处置
begin
set@column=@column+
casewhenlen(@column)=0then
else,
end+@name
set@columndata=@columndata+
casewhenlen(@columndata)=0then
else,,,
end+
casewhen@xtypein(167,175)then++@name++--varchar,char
when@xtypein(231,239)thenN++@name++--nvarchar,nchar
when@xtype=61then+convert(char(23),+@name+,121)+--datetime
when@xtype=58then+convert(char(16),+@name+,120)+--smalldatetime
when@xtype=36then+convert(char(36),+@name+)+--uniqueidentifier
else@name
end
end
end
fetchnextfromsyscolumns_cursorinto@name,@xtype
end
closesyscolumns_cursor
deallocatesyscolumns_cursorset@sql=setnocountonselectinsert+@tablename+(+@column+)values(as--,+@columndata+,)from+@tablenameprint--+@sql
exec(@sql)if@identisnotnull
printSETIDENTITY_INSERT+@TableName+OFF挪用时execOutputDatamyuser个中myUser中以后数据库中存在的表操作被同步到从库上后,则主从都“回天无力”。 |
|