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='""'+@WinRar+'"??a?-ep1?-afzip?-df?-ibck?C:sqlcreatefoldPackage.zip?C:sqlcreatefold"' exec?xp_cmdshell?@shellCommand set?@shellCommand='"?dir?C:sqlcreatefold"' exec?xp_cmdshell?@shellCommand
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END