SQLServer 开启cmd命令

参考地址
https://www.cnblogs.com/OliverQin/p/5032014.html

shell是用户与操作系统对话的一个接口,通过shell告诉操作系统让系统执行我们的指令

xp_cmdshell在sqlserver中默认是关闭的存在安全隐患。

--打开xp_cmdshell
 EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
--关闭xp_cmdshell
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;

以下是跟xp_cmdshell有关的小例子。

1.显示C盘下的内容,这个比较简单

 exec xp_cmdshell 'dir c:\'  
原文地址:https://www.cnblogs.com/life512/p/15571917.html