Trigger to fire XML stream

  • I am a relative beginner to the sql/xml relationship, but i am begging to see the power. Does anyone know how I can generate an xml stream to be generated on the firing of a trigger?

    My aim is to have a trigger broadcast an xml stream to any ip addresses that i want.

    Any help would be greatly appreciated.

    G

    Graham

  • How will you do the broadcast? You typically should not return anything from the trigger, so the next best thing is to write what you want to broadcast into a table. If you want XML, use FOR XML. After that what happens to it is up to you!

    Andy

    http://qa.sqlservercentral.com/columnists/awarren/

  • I already have a statistics table, which has counts that are updated real-time. As the client in question is a call-centre, a real bonus to the Team Managers would be to view these stats updating in real-time. Obviously I want to keep the number of queries on the server to a minimum, so was thinking it would be great if rather than relying on the client polling SQL to get any updated data, how could we push the updates to the client.

    I have found sp_OACreate which could be used to create an instance of a COM object to post the updated xml, but as this would be running on a trigger which fires multiple times a second, the overhead would be too great to go down this route.

    So I guess I have two questions..

    1) Can I use SQLXML to post xml data on a trigger?

    2) If not, can I use sp_OACreate to create a persistant object (rather than creating one instance upon each firing of the trigger)?

  • Not sure what you mean by post. Yes, you can use sp_oacreate.

    Whether or not them querying the server is bad depends on the query. I've got an app coming up soon where they will need to see counts per category, an app running on a separate machine (not the server) will do the processing and aggregate the numbers, users (20 or so) will poll the aggregated table.

    Your idea sounds better, just havent seen a way to make it work smoothly. Seems like ideally some type of ip multicast to get it the subscribers.

    Andy

    http://qa.sqlservercentral.com/columnists/awarren/

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

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