Executing SQL query after a certain point iof Time

In our project, we have a requirement that after receiving an sms message from a third party service provider, after 3 minutes, I need to execute an sql query to update the database.

how should i do it, any suggestions are accepted.

** it is possible to use stored procedures ...

The script is there, we have an intermediary application that believes that it has a web service. from my app, when I send SMS to webservice app via SMS service provider, this system will push to embedded device, this will make the system power on. and after 2 minutes, the device will send an SMS to the target app via the SMS service provider to say the check is in progress ... after receiving this message for sure I need to update the database saying the chekcing is successful. why 3 minutes, because after this time the device will turn off.

Regards, Mahesh

+1


a source to share


3 answers


How exactly do you receive SMS messages. What service picks them up.

There are several ways to do this.

In your application code on SMSReceived Event you can start a separate thread to sleep for 180 seconds and then call the SQL code.

If you want to do this on a database, you need some kind of polling thread.



Write down "TimeReceived" and set the flag "PostProcessed"

Then you can just do the job that runs every 60 seconds that goes

SELECT *
FROM ReceivedSMS
WHERE TimeRecieved < dateadd(second, -180, getdatE()) AND
      PostProcessed = 0

FOREACH Record - Execute SPROC & Update PostProcessed = 1.

      

+5


a source


You can use "SQL jobs" Look at these articles: http://msdn.microsoft.com/en-us/library/ms187910.aspx

http://dacosta9.wordpress.com/2008/10/22/how-to-disable-or-enable-a-sql-server-job-programatically/



Hope it helps.

+3


a source


Start a stored process, but the first line of T-SQL WAITFOR DELAY '00:03:00'

?

0


a source







All Articles