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....

  • 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 Oct 12 at 15:10
  • 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 Oct 12 at 15:13
  • 3
  • 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 Oct 12 at 15:50
  • It was more of a rub you the wrong way kind of question. The record gets inserted in the database from a "middle" software already. It uses a stored procedure, and I read calling an exe from a stored procedure isn't a safe process. But I went ahead and coded my service programs to continually monitor the table looking for records, and it doesn't seem to effect any performance...I just thought there might be a better way. Thanks for the comments guys! – Jeff Oct 18 at 14:18

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

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.