今天在创建数据库的时候突然发现,xp_cmdshell的存储过程不能用了,网上一搜,发现大部分都是只关闭安全配置,然后就有了下文
代码:具体的看注释,值得一提的是==》reconfigure with override,上面一句语句如果不加这句,则只是临时可用,不会影响系统原有配置(可以理解为==》不加就是new和加了就是override)
代码贴上:
--创建目录(如果指定的路径不存在就会报错) exec sp_configure 'show advanced options',1 --显示高级选项 reconfigure with override--重新配置 exec sp_configure 'xp_cmdshell',1 --1代表允许,0代表阻止 reconfigure with override exec xp_cmdshell 'mkdir F:\Work\SQL mkdir E:\SQL' exec sp_configure 'xp_cmdshell',0 reconfigure with override exec sp_configure 'show advanced options',0 reconfigure with override