Home > Database > Mysql Tutorial > sqlserver调用http请求

sqlserver调用http请求

WBOY
Release: 2016-06-07 15:15:19
Original
2203 people have browsed it

首先: 开启使用扩展存储过程权限 sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE; GO EXEC sp_configure 'Ole Automation Procedures'; GO 然后编写存储过程: CREATE PROCEDU

首先:

开启使用扩展存储过程权限
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ole Automation Procedures';
GO

然后编写存储过程:

CREATE PROCEDURE [dbo].[SP_HTTP]
@Parametro varchar(10) = NULL    
AS
    DECLARE @obj INT
    DECLARE @sUrl varchar(200)
    DECLARE @response INT
    
    SET @sUrl = 'http://localhost/test/test.html?id=' + @Parametro
    
    EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @obj OUT
    EXEC sp_OAMethod @obj,'Open', NULL, 'GET', @sUrl, false
    EXEC sp_OAMethod @obj,'Send'
    EXEC sp_OAGetProperty @obj, 'responseText', @response OUT
    
    SELECT @response [response]
    EXEC sp_OADestroy @obj
RETURN


访问http请求需要用到扩展存储过程

不过网上看到说使用扩展存储过程有一定的危险

需要做好安全措施什么的

具体我也没多研究毕竟sqlserver只是玩玩

大概是要分配好权限,这些扩展函数默认是public的之类的




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template