본문 바로가기

Program/DB

SQL Server 에서 API 호출 하기

/* 
exec sp_configure 'show advanced options', 1;   
go   
reconfigure;   
go 
exec sp_configure 'Ole Automation Procedures', 1;   
go   
reconfigure;   
go  
*/ 


declare 
    @obj int 
,   @response nvarchar(4000) 

exec sp_OACreate 'MSXML2.XMLHTTP', @obj out; 
exec sp_OAMethod @obj, 'open', NULL, 'get', 
                 'https://호출할 API 주소', 
                 'false' 
exec sp_OAMethod @obj, 'send' 
exec sp_OAMethod @obj, 'responseText', @response output 

select @response 

exec sp_OADestroy @obj

 

출처 : http://databaser.net/moniwiki/wiki.php/SQLServer%EC%97%90%EC%84%9CHTTPCall%ED%95%98%EA%B8%B0