Can you call a webservice from TSQL code?

前端 未结 9 1859
野趣味
野趣味 2020-11-29 00:39

Is there a way to call out from a TSQL stored procedure or function to a webservice?

9条回答
  •  生来不讨喜
    2020-11-29 00:51

    You can do it with the embedded VB objects.

    First you create one VB object of type 'MSXML2.XMLHttp', and you use this one object for all of your queries (if you recreate it each time expect a heavy performance penalty).

    Then you feed that object, some parameters, into a stored procedure that invokes sp_OAMethod on the object.

    Sorry for the inprecise example, but a quick google search should reveal how the vb-script method is done.

    --

    But the CLR version is much....MUCH easier. The problem with invoking webservices is that they cannot keep pace with the DB engine. You'll get lots of errors where it just cannot keep up.

    And remember, web SERVICES require a new connection each time. Multiplicity comes into play. You don't want to open 5000 socket connections to service a function call on a table. Thats looney!

    In that case you'd have to create a custom aggregate function, and use THAT as an argument to pass to your webservice, which would return a result set...then you'd have to collate that. Its really an awkward way of getting data.

提交回复
热议问题