HTTP GET in T-SQL

  • I have an instrument (thermometer) with a built-in web server that responds to a HTTP Get statement and returns a string (Probe1|25.6|Probe 2| 28.4).

    I need to figure out how to run the GET command from a stored procedure (or DTS) so I can load the string into the database at regular intervals through scheduled job.

    Any suggestions?

     

    Thanks,

    Jakub

  • Hi,

    My first idea would be to use DTS, and have a look at ActiveX Script Task and use XMLHTTP ...

    Found smth on Google also, tested it, works. See http://dbforums.com/t903687.html.

    Make sure you notice the difference between ServerXMLhttp and XMLhttp.

    Have fun!

     

    '**********************************************************************

    '  Visual Basic ActiveX Script

    '************************************************************************

    Function Main()

     dim strURL, oBrowser

     dim serverPath

     dim scriptPath

     serverPath = "http://www.hr-technologies.com/content/"

     scriptPath = "page.asp"

     strURL =serverPath & scriptPath

     set oBrowser = CreateObject("Microsoft.XMLHTTP")

     oBrowser.Open "GET" , strURL , false , "" , ""

     oBrowser.send

     msgbox oBrowser.responsetext

     set oBrowser = nothing

     Main = DTSTaskExecResult_Success

    End Function

  • Worked like a charm!!

    Thanks!

  • When i run the script from the Package Window it works fine, but when I call the Package using the sp_OACreate in a Stored Procedure. The responseText does not work. Any suggestions? I am trying to save the xml file using responseXML.save and that does not work either.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply