来源:https://blog.csdn.net/smartsmile2012/article/details/53704227
/*
Sqlserver数据库开始相关服务
以下示例显示了如何查看 OLE Automation Procedures 的当前设置。0未启用
*/
EXEC sp_configure \'show advanced option\', \'1\' --只有这个高级选项被打开的时候,才有权限修改其他配置。
go
RECONFIGURE --运行RECONFIGURE语句进行安装,也就是说,使以上语句生效
go
EXEC sp_configure \'Ole Automation Procedures\';
GO
--启用Ole Automation Procedures
sp_configure \'show advanced options\', 1;
GO
RECONFIGURE;
GO
sp_configure \'Ole Automation Procedures\', 1;
GO
RECONFIGURE;
GO
Drop Proc [dbo].[pro_NotifyApp]
go
---通过sql server 2008 调用应用程序
CREATE PROCEDURE [dbo].[pro_NotifyApp](
@Id NVARCHAR(20),
@Content NVARCHAR(MAX)
)
AS
BEGIN
declare @ServiceUrl as varchar(1000)
PRINT \'http://localhost:789/home/GetNotify?id=\' + @Id + \'&message=\' + @Content
--通过http协议调用的接口地址\'
set @ServiceUrl = \'http://localhost:789/home/GetNotify?id=\' + @Id + \'&message=\' + @Content
SEt @ServiceUrl=\'http://172.16.1.5:10030/api/dingding.ashx?t=test\'
Declare @Object as Int
Declare @ResponseText as Varchar(8000)
Exec sp_OACreate \'MSXML2.XMLHTTP\', @Object OUT;
Exec sp_OAMethod @Object, \'open\', NULL, \'get\',@ServiceUrl,\'false\'
Exec sp_OAMethod @Object, \'send\'
Exec sp_OAMethod @Object, \'responseText\', @ResponseText OUTPUT
Select @ResponseText
Exec sp_OADestroy @Object
END
Exec [pro_NotifyApp] @Id=\'1\',@Content=\'test\'
版权声明
本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。


