Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Scheduling a job to run every 30 seconds...

 
   Database Forums (Home) -> Notification Services RSS
Next:  SQL-NS Discontinued???  
Author Message
Roz

External


Since: Mar 07, 2005
Posts: 4



(Msg. 1) Posted: Thu Jun 21, 2007 11:20 am
Post subject: Scheduling a job to run every 30 seconds...
Archived from groups: microsoft>public>sqlserver>notificationsvcs (more info?)

Hello, all. I need to schedule a SQL job to run every 30 seconds. However,
it looks like the shortest frequency SQL will allow is every minute. Is what
I want to do possible?

Thnx in advance,

Roz

 >> Stay informed about: Scheduling a job to run every 30 seconds... 
Back to top
Login to vote
Adam Machanic

External


Since: Jun 26, 2007
Posts: 39



(Msg. 2) Posted: Thu Jun 21, 2007 2:35 pm
Post subject: Re: Scheduling a job to run every 30 seconds... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I don't believe you can go below one minute, but you can work around it
easily enough. In your job, set up a loop:


DECLARE @i INT
SET @i = 1
WHILE @i > 0
BEGIN
/*
do whatever work you need to do, here
*/

WAITFOR DELAY '00:00:30'

SET @i = @i - 1
END


You might have to tweak the WAITFOR interval a bit, depending on how
long the work actually takes to do. But if you wanted to get a bit
fancier--and more exact--with it, you could do something like:


DECLARE @startTime DATETIME
SET @startTime = GETDATE()

DECLARE @i INT
SET @i = 1
WHILE @i > 0
BEGIN
/*
do whatever work you need to do, here
*/

WHILE DATEDIFF(second, @startTime, GETDATE()) < 30
WAITFOR DELAY '00:00:01'

SET @i = @i - 1
END


--

Adam Machanic
SQL Server MVP

Author, "Expert SQL Server 2005 Development"
http://www.apress.com/book/bookDisplay.html?bID=10220



"Roz" wrote in message

> Hello, all. I need to schedule a SQL job to run every 30 seconds.
> However,
> it looks like the shortest frequency SQL will allow is every minute. Is
> what
> I want to do possible?
>
> Thnx in advance,
>
> Roz

 >> Stay informed about: Scheduling a job to run every 30 seconds... 
Back to top
Login to vote
Adam Machanic

External


Since: Jun 26, 2007
Posts: 39



(Msg. 3) Posted: Thu Jun 21, 2007 2:41 pm
Post subject: Re: Scheduling a job to run every 30 seconds... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Oops, that should have been @i >= 0 in both loops, rather than @i > 0.


--

Adam Machanic
SQL Server MVP

Author, "Expert SQL Server 2005 Development"
http://www.apress.com/book/bookDisplay.html?bID=10220



"Adam Machanic" wrote in message

>I don't believe you can go below one minute, but you can work around it
>easily enough. In your job, set up a loop:
>
>
> DECLARE @i INT
> SET @i = 1
> WHILE @i > 0
> BEGIN
> /*
> do whatever work you need to do, here
> */
>
> WAITFOR DELAY '00:00:30'
>
> SET @i = @i - 1
> END
>
>
> You might have to tweak the WAITFOR interval a bit, depending on how
> long the work actually takes to do. But if you wanted to get a bit
> fancier--and more exact--with it, you could do something like:
>
>
> DECLARE @startTime DATETIME
> SET @startTime = GETDATE()
>
> DECLARE @i INT
> SET @i = 1
> WHILE @i > 0
> BEGIN
> /*
> do whatever work you need to do, here
> */
>
> WHILE DATEDIFF(second, @startTime, GETDATE()) < 30
> WAITFOR DELAY '00:00:01'
>
> SET @i = @i - 1
> END
>
>
> --
>
> Adam Machanic
> SQL Server MVP
>
> Author, "Expert SQL Server 2005 Development"
> http://www.apress.com/book/bookDisplay.html?bID=10220
>
>
>
> "Roz" wrote in message
>
>> Hello, all. I need to schedule a SQL job to run every 30 seconds.
>> However,
>> it looks like the shortest frequency SQL will allow is every minute. Is
>> what
>> I want to do possible?
>>
>> Thnx in advance,
>>
>> Roz
>
 >> Stay informed about: Scheduling a job to run every 30 seconds... 
Back to top
Login to vote
Roz

External


Since: Mar 07, 2005
Posts: 4



(Msg. 4) Posted: Thu Jun 21, 2007 2:41 pm
Post subject: Re: Scheduling a job to run every 30 seconds... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Adam,

I will try your suggestion. Though, it looks like it'll work for me.

Thanks so much.

Roz


"Adam Machanic" wrote:

> Oops, that should have been @i >= 0 in both loops, rather than @i > 0.
>
>
> --
>
> Adam Machanic
> SQL Server MVP
>
> Author, "Expert SQL Server 2005 Development"
> http://www.apress.com/book/bookDisplay.html?bID=10220
>
>
>
> "Adam Machanic" wrote in message
>
> >I don't believe you can go below one minute, but you can work around it
> >easily enough. In your job, set up a loop:
> >
> >
> > DECLARE @i INT
> > SET @i = 1
> > WHILE @i > 0
> > BEGIN
> > /*
> > do whatever work you need to do, here
> > */
> >
> > WAITFOR DELAY '00:00:30'
> >
> > SET @i = @i - 1
> > END
> >
> >
> > You might have to tweak the WAITFOR interval a bit, depending on how
> > long the work actually takes to do. But if you wanted to get a bit
> > fancier--and more exact--with it, you could do something like:
> >
> >
> > DECLARE @startTime DATETIME
> > SET @startTime = GETDATE()
> >
> > DECLARE @i INT
> > SET @i = 1
> > WHILE @i > 0
> > BEGIN
> > /*
> > do whatever work you need to do, here
> > */
> >
> > WHILE DATEDIFF(second, @startTime, GETDATE()) < 30
> > WAITFOR DELAY '00:00:01'
> >
> > SET @i = @i - 1
> > END
> >
> >
> > --
> >
> > Adam Machanic
> > SQL Server MVP
> >
> > Author, "Expert SQL Server 2005 Development"
> > http://www.apress.com/book/bookDisplay.html?bID=10220
> >
> >
> >
> > "Roz" wrote in message
> >
> >> Hello, all. I need to schedule a SQL job to run every 30 seconds.
> >> However,
> >> it looks like the shortest frequency SQL will allow is every minute. Is
> >> what
> >> I want to do possible?
> >>
> >> Thnx in advance,
> >>
> >> Roz
> >
>
 >> Stay informed about: Scheduling a job to run every 30 seconds... 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
This Subscription will self-destruct in 5 seconds... - I am building a membership-based site and plan to use NS to send out various kinds of scheduled and triggered notifications. The first notification that will be sent out is a 'Welcome to the site!' message. Of course I could just send it out the..

Scheduling delivery of messages - HI All can we schedule the delivery of messages to email using NS itself. The scenario is like this: I want all the messages are diplayed in the website when they are generated but delivery should be in a different date of users convineance...

NS API Question - Is it possible to have an arseembly in SQL 2005 to expose the NS API? The idea is to have interfaces exposed as web services from SQL 2005 directly that allow for the management of NS subscriptions. This would allow the existing ASP.Net 1.1 code to cal...

Clean out??? - I was asked to look into a problem a customer was having , Turned out they moved SMTP server and in the process the generator got disabled. This was back in May. So I have that all squared away and now I'm looking for a quick way to clear out the..

sql mail integration - i have configured sql mail in sql server 2000. the mailid is also successfully getting tested. but when i execute the xp_sendmail command i get the following error Server: Msg 18025, Level 16, State 1, Line 0 xp_sendmail: failed with mail error..
   Database Forums (Home) -> Notification Services All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]