数据库
首页 > 数据库> > SQLServer 开启cmd命令

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:\'  

标签:sp,configure,cmdshell,EXEC,cmd,SQLServer,开启,RECONFIGURE,xp
来源: https://www.cnblogs.com/life512/p/15571917.html