SQL Server stored procedure, call web api interface

stored procedure SQL

CREATE PROCEDURE [dbo].[SP_RequestAPI]
AS
BEGIN
	exec sp_configure 'show advanced options', 1;	
	RECONFIGURE;	
	exec sp_configure 'Ole Automation Procedures', 1;	
	RECONFIGURE;	

	declare @ServiceUrl as varchar(1000) 
	--api接口地址
	set @ServiceUrl = 'http://localhost/api/'                    
                  
	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
    
	 
	Exec sp_OADestroy @Object

END

Guess you like

Origin blog.csdn.net/vaecnfeilong/article/details/129622752