OK, first of all, think about not doing this at all. Disabling all the useful work with periodic tasks that are configured in the database is a fragile design that breaks easily when someone improperly adjusts the situation (easy to do, because you need fairly advanced triggers to check if the schedule is consistent), and also tends to create an incomprehensible system when there really are hidden dependencies in tasks (if A did not run for some time before B, interruptions, something like that). Source: personal experience with three such systems in three different companies and three different platforms / technologies, and somehow they all suffered from the same problems, so, apparently, this is something. Think, just write out what you want to plan, like plain old code, with a configuration file. Sure, this will not be so general, but the people who need to support it will be grateful to you, especially because their needs are becoming more complex.
SqlDependency quite volatile and not very usable, even if you have a supported query. In your case, as you noticed, this does not work, because the database engine will not publish a notification if the data does not actually change - it does not matter that the results of the query change over time. As Nick noted, polling a database every 5 seconds is usually just fine. This creates a small load, provided that you create an index on mydb.timestamp (and create it, this is very important, because doing a table scan every 5 seconds is not OK).
The only objection is latency: if any schedule updates should be performed earlier than once every 5 seconds, the survey is not good enough. In this case, you can use Service Broker and send a notification to the queue that something has changed (possibly from a trigger). In fact, SqlDependency uses the same approach under covers, so you can create a SELECT * FROM table dependency to be notified when nothing changes in the table, and then execute the actual query to get what you need (possibly not finding anything) . Beware, however: getting the code for this correctly without getting confused by a few quick updates, or disconnecting is not trivial and probably not worth it, and not just restarting periodically.
source share