Skip to content

Instantly share code, notes, and snippets.

@jbnv
Created July 8, 2015 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbnv/19f36d329e992a319e34 to your computer and use it in GitHub Desktop.
Save jbnv/19f36d329e992a319e34 to your computer and use it in GitHub Desktop.
Calling a Web service from T-SQL
DECLARE @Object AS INT;
DECLARE @ResponseText AS VARCHAR(8000);
EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
EXEC sp_OAMethod @Object, 'open', NULL, 'get',
'http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=MSFT', --Your Web Service Url (invoked)
'false'
EXEC sp_OAMethod @Object, 'send'
EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
SELECT @ResponseText
EXEC sp_OADestroy @Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment