SQL xp_cmdshell

大家讲道理
リリース: 2016-11-10 11:15:10
オリジナル
966 人が閲覧しました

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:\sqlcreatefold\1.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:\sqlcreatefold\1.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:\sqlcreatefold\1.txt''')
select * From ##temp
drop table ##temp
 
GO
--调用RAR--压缩文件夹
declare @shellCommand nvarchar(1024)
declare @WinRar varchar(128)
set @WinRar='C:\Program Files\WinRAR\WinRAR.exe'
Set @shellCommand='""'+@WinRar+'"  a -ep1 -afzip -df -ibck C:\sqlcreatefold\Package.zip C:\sqlcreatefold"'
exec xp_cmdshell @shellCommand
set @shellCommand='" dir C:\sqlcreatefold"'
exec xp_cmdshell @shellCommand
ログイン後にコピー

ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!