Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Having a SQL job constantly run

Posted on 2011-02-21
4
Medium Priority
?
267 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
ID: 34943195
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
ID: 34943330
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
ID: 34943733
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 2000 total points
ID: 34944149
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

824 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