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
Thomas
source
to share
3 answers
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 to share