Question SQL job getting stuck - how do I prevent this?

Sullivan27

New member
Joined
Jan 31, 2013
Messages
1
Programming Experience
Beginner
I have a simple SQL job that occasionally gets stuck moving files from one folder to another. It executes every 10 minutes, and I assume the entire movement of files only takes a minute or less. Twice last week it got stuck somehow. I was considering adding a while condition on a timer to exit if the movements take longer than 5 minutes such as:
STARTTIME = TIMER
ELAPSED = TIMER - STARTTIME
DO WHILE ELAPSED < 300
' MOVE INSTRUCTION
LOOP
but that will not help me if it is stuck on one particular file, and I really don't need the files to be moved more than once. I am a newbie, and would appreciate all your help. Here is the code:
Function Main()
Main = DTSTaskExecResult_Success

Dim currFolder ,FileName,To_Folder
Dim f, f1, fc

currFolder = "D:\GENERAL_OUTPUT_WIP\"
To_Folder = "D:\GENERAL_OUTPUT\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(currFolder)
Set fc = f.Files
' Check for file and Execute the Move.File Command
For Each f1 In fc
fso.MoveFile "D:\GENERAL_OUTPUT_WIP\*.xml","D:\GENERAL_OUTPUT\"
Next

Set fso = Nothing
Set currFolder = Nothing
Set To_Folder = Nothing
Set f1 = Nothing
Set fc = Nothing

End Function
 
I'm not really sure why you call this a SQL job, as there is nothing even connecting to a SQL server in this script. Second, this is VBScript, not VB.net. With that said, it is futile to try to cope with the fact that it is getting stuck, you should instead figure out WHY it is getting stuck and remedy that problem.
 
I think that the connection may be that that is a SQL Server DTS script task. If it really is DTS then it's not VB.NET so it doesn't belong on this site. DTS was upgraded to SSIS (Integration Services) and script tasks are now written in VB.NET. If you're going to use SSIS then we can help. If you're using DTS then we can't and this thread will be closed.
 
Back
Top