Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Programatic events possible in SQL Server

Tags:

sql-server

Scenario: An application is started, it connects to the DB and registers itself to listen for a specific event name. Then using either a trigger or stored procedure when certain criteria are met the event may be raised. The DB then notifies all the applications that have registered that they are listening for that event. The application is then able to act and go and do some processing. This saves the program from having to constantly poll the database to see if the criteria has been met.

This scenario is possible with Interbase / FirebirdSQL but is it possible to do with SQL Server (2005 or higher) and if so what should I be looking for as I am strugling to find any information on this sort of thing. If it is not possible then is there a better way to handle this scenario to not have to poll.

like image 389
FireClaw Avatar asked Dec 14 '25 20:12

FireClaw


1 Answers

Yes. You can use Service Broker notifications for this.

Though I guess the caveat in this article about not having too many clients registered will still apply. How many clients might you have awaiting notifications?

like image 133
Martin Smith Avatar answered Dec 18 '25 23:12

Martin Smith