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

Scheduling a job to run every 30 seconds...

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

External


Since: Oct 17, 2006
Posts: 5



(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: Jan 21, 2008
Posts: 7



(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" <Roz.TakeThisOut@discussions.microsoft.com> wrote in message
news:BE9B5953-9687-4D3C-9DE7-7FC22B189EF4@microsoft.com...
> 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: Jan 21, 2008
Posts: 7



(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" <amachanic RemoveThis @IHATESPAMgmail.com> wrote in message
news:16FCEC2A-E80B-4418-AD19-A1D573065877@microsoft.com...
>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" <Roz RemoveThis @discussions.microsoft.com> wrote in message
> news:BE9B5953-9687-4D3C-9DE7-7FC22B189EF4@microsoft.com...
>> 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: Oct 17, 2006
Posts: 5



(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" <amachanic.TakeThisOut@IHATESPAMgmail.com> wrote in message
> news:16FCEC2A-E80B-4418-AD19-A1D573065877@microsoft.com...
> >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" <Roz.TakeThisOut@discussions.microsoft.com> wrote in message
> > news:BE9B5953-9687-4D3C-9DE7-7FC22B189EF4@microsoft.com...
> >> 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:   
   Database Help (Home) -> Notification Services All times are: Pacific Time (US & Canada) (change)
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 ]