SQL Server: Can I use EXEC to run an external Application?

a 夏天 提交于 2019-12-23 19:27:00

问题


Hello and thank you for your time,

I have been searching everywhere online for an example, where a SQL trigger will run an external application, but I have had no luck. All I am seeing is that the EXEC will execute a SQL procedure.

The reason I need this is, I have a SQL Server 2010 with many tables and when an update or insert occurs on certain tables I need my Talend job to run and update the Salesforce tables.

Currently the Talend jobs are running through A task scheduler but the company wants the information to move right away.

Currently this is my code

CREATE TRIGGER UP_ACCOUNT ON ARCUS
AFTER INSERT, UPDATE
AS 

IF(exists(SELECT IDCUST FROM inserted WHERE IDCUST IS NOT NULL))
    BEGIN 
        EXEC [name_of_application]
    END

I still need to do all the checks to make sure this will not crash anything, but the EXEC statement does not seem to want to execute external commands. Any suggestions would be greatly appreciated.

Thank you


回答1:


complementing the answr on that post...I would never call another app from sql. Several reasons for that, since security until the fact that someone may move the app and you would need to update your trigger, which means you are responsible for the direct communication between trigger and app.

What I would do is make your trigger write to a table and then have a process that monitors that table (reads and delete rows) and than calls the application. I know you ahve another player but is safier and easier to mantain.




回答2:


Maybe job, it's what you need.




回答3:


I solved this problem with SSSB http://msdn.microsoft.com/en-us/library/bb522893.aspx it helps you to send messages to external apps, also communicatino to other databases.



来源:https://stackoverflow.com/questions/12974832/sql-server-can-i-use-exec-to-run-an-external-application

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