SQL Server Agent: How to Sleep?

During the script phase in a scheduled task in SQL Server Agent 2005, I need to run a web script that runs on a different server. I'm doing it:

Dim ie 
Set ie = CreateObject( "InternetExplorer.Application" )

ie.navigate "...to my dreamscript"

' Wait till IE is ready
Do While ie.Busy
    (1)
Loop

ie.Quit
set ie = Nothing

      

In (1) I would like to "sleep" (eg WScript.sleep (..)), but WScript is not available in this environment. Is there another way to "sleep" for a while?

0


source to share


3 answers


You can write a console application and execute the console application in a SQL Agent job.



+1


source


If you are only trying to start an SErver SQL Agent task waiting for a specific period of time, use the T-SQL task using script

WAITFOR DELAY '01: 00: 00 '- wait an hour



and change the time to the time you want to wait.

NTN Andy

+2


source


You can execute wscript using a SQL Server Agent task of type "Operpating System (CmdExec)". This requires xp_cmdshell to be enabled and is often disabled (by default) due to security concerns. However, it allows you to run programs like wscript that run on the command line.

You can move the code to SQLCLR, where you can write a stored procedure in C # or VB.Net. The VCL.NET SQLCLR code would be very similar to your original wscript.

0


source







All Articles