Sql-server – Launch a stored procedure when a datetime is expired

sql serversql-server-2016stored-procedures

Can I launch in SQL Server a stored procedure when a datetime value (stored in a table) is expired?

I have a stored procedure that will send a message with MSMQ, and I need to do this as soon as the datetime is expired.

I am using SQL Server 2016.

Best Answer

Here is another option:

It would require a little more 'setup', but have a look at Service Broker timer and activation. Here is an example of how you might utilize this functionality. Service Broker even works on Sql Express (which doesn't have the Sql Agent).