开发者

SQL Trigger to run .Net aplication, can you do this?

I know nothing about MS SQL Server but need to know if it's possible to set some kind of trigger that whenever a criteria is met it will call a C# .exe and pass it a field for the database?

So whenever a new 开发者_StackOverflow社区row is added it causes a C# app to run and passes it a value from the row...

Hope that makes sense to someone!

If so how do you add it? I think it's SQL 2003.


Have you thought of looking into a ssis package? This provides simple interaction between sql and c#.


You can use CLR Triggers http://msdn.microsoft.com/en-us/library/ms131093(SQL.100).aspx


There are two ways you can do this. First, you can use a CLR trigger.

Second, you could use xp_cmdshell to shell out to another app to get a value.

Both are what I would consider to be very, very bad ideas, especially if your knowledge of SQL Server is limited. I would strongly, strongly consider not performing operations like the ones you're attempting inside of a trigger. There are serious performance and security considerations to take into account either way you do it.

Instead of attempting to do what you're doing, I would suggest changing your application's code to perform updates like this there.


This seems like a bad idea — there is a probably a better way to implement what you are trying to do. Can you provide more details around the business need?


Why dont you just write a sql trigger to write to a table. Then poll with c# that table and look for a flag code and use that to invoke the c# message.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜