--启用xp_cmdshell
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
--执行xp_cmdshell,映射一下
exec master..xp_cmdshell 'net use z: //192.16.18.2/e$/backup "ade123456" /user:192.16.18.2/administrator'
z:是映射网络路径对应本机的盘符,与下面的备份对应 ,
//192.16.18.2/e$/backup是要映射的网络路径
192.16.18.2/administrator
192.16.18.2 是远程的计算机IP,
administrator 是登陆的用户名
ade123456 是administrator用户的密码
--关闭xp_cmdshell
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;
RECONFIGURE;
本文介绍如何在SQL Server中使用xp_cmdshell扩展存储过程进行文件系统操作,包括开启、执行及关闭该功能的方法,并提供了具体的命令示例。

被折叠的 条评论
为什么被折叠?



