0

Can anyone suggest how to call a c# routine from a SQL server database? Thanks

I have a SQL Server database and each time a record is inserted through an MS Access front end, I want it to call a C# routine on a web server to email users who have subscribed to each record.

Andy

1
  • Trevor Pilleys answer is technically correct - you should however note that this will cause a major performance penalty and also probably make your DB hard to maintain. I would much rather solve this at the application level rather than in the database. Commented Aug 4, 2014 at 13:56

3 Answers 3

2

You could create an INSERT trigger on the table and use that to invoke SQL CLR code, that allows you to execute a .NET method based upon the INSERT happening and you can even pass values from the inserted row into the .NET code itself.

Sign up to request clarification or add additional context in comments.

Comments

0

Check out the SqlDependency feature.

http://msdn.microsoft.com/en-us/library/62xk7953(v=vs.110).aspx

3 Comments

SqlDependency implementations are complex. Providing a full implementation that addresses the poster's scenario is not practical. Are you implying that the link should have been provided in a comment, not an answer?
@RobEpstein: Most probably yes!! Of course this guide the OP, but this doesn't answer the question directly. Not a big deal I guess, unless this link goes offline
0

You can create a database trigger on an insert event into your table which calls your java executable.

Here are two helpful links for calling an executable from SQL Server using T-SQL:

3 Comments

Except the question was about C# rather than Java.
It's a question about running an executable... doesn't matter what type of executable - that command will do what he wants.
True, but since SQL Server has built in support for calling code in CLR assemblies, using that feature in this case makes much more sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.