How to catch that trigger was running on sql server

I have a table in SQL, and when there is an insert in this table, I want to print this inserted data.

What am I thinking about:

  • Create a trigger in this table.
  • Handle the print event in C # after the trigger fires.

My problem

I do not know the name of the function that runs the C # code when the trigger fires.

Can you help me with this problem please?

+5
source share
1 answer

There are several ways to solve this problem, and the sototon depends on the architecture of the system (resolution, availability) and knowledge for its implementation.

Basically, these are parameters that are affected by these factors:

  • print directly from the paste application or a notification from the paste application: can you change this application? Is it possible to contact the print application from this application? (It can be implemented, for example, with WCF)
  • sql dependencies (SQL notification request) : the print application must create and subscribe to the sql dependency: do you have permission to create dependencies on the server?
  • poll: quick and dirty solution: use the "timer" to check if there is new data and print it when it is available.

The last solution is one that will pose the least problems. It is not smart, but very easy to implement. You can adjust the polling period depending on the expected number of messages and the "real-time" requirements of the pringing application.

+1
source

Source: https://habr.com/ru/post/1201543/


All Articles