日期:2014-05-18  浏览次数:20420 次

我在SQL的触发器里 ,怎么去调用EXE
看了http://topic.csdn.net/u/20081219/17/760e553e-7a54-4c1f-9388-67e59ee1e621.html
的帖子
然后在查询分析器里这么写的
declare @str varchar(255)
set @str='C:\Documents and Settings\Administrator\桌面\应用程序.exe'
print @str  
exec master..xp_cmdshell @str 

运行提示错误

消息 15281,级别 16,状态 1,过程 xp_cmdshell,第 1 行
SQL Server 阻止了对组件 'xp_cmdshell' 的 过程 'sys.xp_cmdshell' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'xp_cmdshell'。有关启用 'xp_cmdshell' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。

额,谁能给个通过使用 sp_configure 启用 'xp_cmdshell'的代码,谢谢了!

------解决方案--------------------
SQL code

--开启xp_cmdshell
--SQL Server blocked access to procedure 'xp_cmdshell'
sp_configure 'show advanced options', 1
go
reconfigure
go
sp_configure 'xp_cmdshell', 1
go
reconfigure
go

--开启sp_OACreate
--SQL Server blocked access to procedure 'sys.sp_OACreate'
sp_configure 'show advanced options', 1;
go
reconfigure;
go
sp_configure 'ole automation procedures', 1;
go
reconfigure;
go


sp_configure 'Ad Hoc Distributed Queries',1;
go
reconfigure
go

------解决方案--------------------
SQL code
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO

------解决方案--------------------
SQL code
--开启xp_cmdshell
--SQL Server blocked access to procedure 'xp_cmdshell'
sp_configure 'show advanced options', 1
go
reconfigure
go
sp_configure 'xp_cmdshell', 1
go
reconfigure
go

--开启sp_OACreate
--SQL Server blocked access to procedure 'sys.sp_OACreate'
sp_configure 'show advanced options', 1;
go
reconfigure;
go
sp_configure 'ole automation procedures', 1;
go
reconfigure;
go


sp_configure 'Ad Hoc Distributed Queries',1;
go
reconfigure
go