I need to check for the existence of a record in an SQL database. If it exists, create a printer stream and send it to a label printer.

My issue is that I have as many as 20 of these services running at a time. It seems like a bad practice to continually monitor the tables for data, but I cannot come up with a better solution. Any suggested methods? I know that calling an external EXE from an SQL trigger is not recommended, but there has to be a better way....

New contributor
Jeff is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    To help address your concerns better, why is this a problem? Is it impacting performance? Causing a noisy network and overloading a switch or router? Or does it just rub you the wrong way? – Becuzz 2 days ago
  • Could you use a "middle" piece of software? Have that be a single program with a single connection periodically checking for a new records and taking a copy if one is found; then have your 20+ services interrogate that – Kai 2 days ago
  • 2
  • What is creating the records in the database, and why can't you simply hook into that event somehow? What if that process begins using some other persistence type instead? – Dan Wilson 2 days ago

As with all 'do something when x happens' questions the key is to capture the incoming event, rather than to watch for its effects.

Hide your database behind an API, in the Update methods of the api, check your conditions and trigger your event as required.

Your Answer

Jeff is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.