Solved

Having a SQL job constantly run

Posted on 2011-02-21
4
256 Views
Last Modified: 2012-05-11
Is it possible to program a SQL job to run constantly?  I have a very simple SQL update script that I would like to have run as a job, literally, every second.  Unfortunately, it appears that the most that SQL can do is to run a job every 60 seconds.
0
Comment
Question by:apitech
  • 2
4 Comments
 
LVL 11

Expert Comment

by:rajvja
Comment Utility
Hi,

   Are you sure that you want to run for every second????
Establishing the connection and execute statement will take a while(typically more than a second).
And also burden on server if you run like that
0
 
LVL 4

Expert Comment

by:rocky_lotus_newbie
Comment Utility
If you are convinced, you need to run it every second - There is an alternative, to include the script in an infinite while loop (while 1=1) with a Waitfor command (SYNTAX: WAITFOR DELAY '000:00:01').

This does not run the script for every second but will ensure that there is a time gap of 1 ssecond between successive executions.

Please consider implementing this only if you think it meets ur requirements as running something for every 1 second is not advisable.

Thanks,
0
 
LVL 1

Author Comment

by:apitech
Comment Utility
Hi rocky_lotus_newbie:

I don't mind a gap of one second.  If I use the syntax that you used, such as WAITFORDELAY '000:00:01', would that do what you're suggesting (i.e. have a gap of one second) and allow for a safe run of my script?
0
 
LVL 4

Accepted Solution

by:
rocky_lotus_newbie earned 500 total points
Comment Utility
Yes, Below is the Syntax. Make sure you test it few times before implementing.

while (1=1)
BEGIN
-- Write your Query/Script here
WAITFOR DELAY '000:00:01'
END
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now