SQL xp_cmdshell
发布时间:2020-12-25 05:56:14 所属栏目:MySql教程 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 GO---打开xp_cmdshellEXEC sp_configure 'show advanced options',1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell',1;RECONFIGUREGO---创建文件夹decl
|
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 GO
---打开xp_cmdshell
EXEC sp_configure 'show advanced options',1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell',1;
RECONFIGURE
GO
---创建文件夹
declare @shellCommand nvarchar(1024)
Set @shellCommand='"mkdir C:sqlcreatefold"'
exec xp_cmdshell @shellCommand
GO
--复制文件--准备一个空的文本文件在C盘
declare @shellCommand nvarchar(1024)
Set @shellCommand='Copy "C:1.txt'+'" "C:sqlcreatefold1.txt'+'"'
exec xp_cmdshell @shellCommand
GO
--导出数据到TXT
Create table ##temp(line varchar(100))
Insert into ##temp(line)values('asdfghjklasdfghjkl')
Insert into ##temp(line)values('一二三四五六七')
declare @shellCommand nvarchar(1024)
Set @shellCommand='bcp "Select line From ##temp" queryout C:sqlcreatefold1.txt'+' -S"." -U"sa" -P"123456" -c -T'
exec xp_cmdshell @shellCommand
drop table ##temp
GO
--读取TXT文件
Create table ##temp(line varchar(100))
exec(N'bulk insert ##temp from N''C:sqlcreatefold1.txt''')
select * From ##temp
drop table ##temp
GO
--调用RAR--压缩文件夹
declare @shellCommand nvarchar(1024)
declare @WinRar varchar(128)
set @WinRar='C:Program FilesWinRARWinRAR.exe'
Set @shellCommand='""'[email?protected]+'" a -ep1 -afzip -df -ibck C:sqlcreatefoldPackage.zip C:sqlcreatefold"'
exec xp_cmdshell @shellCommand
set @shellCommand='" dir C:sqlcreatefold"'
exec xp_cmdshell @shellCommand
以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:清远站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |



