Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Execute a procedure after a countdown?

Author  Topic 

urungu
Starting Member

2 Posts

Posted - 2007-07-04 : 16:46:28
When I click a button in a web application it will start a countdown in sql server for example 4 hours, after 4 hours completed a procedure will be executed automatically in database.
How can I manage something like this?


spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-04 : 16:49:33
try using
Waitfor delay

look it up in BOL

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

urungu
Starting Member

2 Posts

Posted - 2007-07-05 : 02:23:48
quote:
Originally posted by spirit1

try using
Waitfor delay

look it up in BOL

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp



Thanks.it can be useful.But what happens when I run for example 1000 copies of this procedure.Is it efficient?Can Sql server handle to run this large numbers of waiting procedures simultaneously?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-07-05 : 02:29:26
Seriously you should create and schedule job for such tasks rather than resorting to T-SQL workarounds.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-05 : 05:40:56
I would have a job that runs frequently - every minute if needs be.

I would then have a table of "actions" and "Start Time" for that job to check. It should run any overdue "task".

Or you could insert a new job into SQL Server's schedule if you like - but from the sound of it I think you would be better off with something more under your control.

One of the good things about this approach is that you can control that Job-B must not start until Job-A has finished - bit difficult to do with SQL Server's scheduler. We have a single scheduled task per database that runs the jobs within the database, and that way we are sure that they will run sequentially, and not overlap!

Kristen
Go to Top of Page
   

- Advertisement -