SQL Service Broker to notify external app

这一生的挚爱 提交于 2019-12-11 12:17:27

问题


After much searching on Service Broker, I came across this question and answer:

My scenario is similar to the one mentioned there, in that I have a SQL trigger on a table, and in this trigger I'm calling xp_cmdshell to pass primary key information to an external exe.

I can see the value of setting up a Service Broker queue and service instead of using a trigger on a table. As I understand it, the activation sproc that I set up to process messages in the queue would now contain my call to xp_cmdshell.

However, I can't figure out how to hook up a "change to data in a table" event as the triggering event. I would expect the CREATE EVENT NOTIFICATION clause to have an ON TABLE [x] FOR [INSERT|UPDATE] part to it, but it does not.

Any pointers would be appreciated.


回答1:


The link you provided actually gives a great answer to your question. As described here, event notification feature is really meant for DDL and database state changes. What you want is probably to stick with triggers, but make the xp_cmdshell call asynchronous. I really don't think any better answer can be provided than the one Remus gave to the linked question.



来源:https://stackoverflow.com/questions/5308711/sql-service-broker-to-notify-external-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!