Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2004, 03:25 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to delay and loop until file arrives

I have a situation where a file is sent every hour and overwrites the old file. The time it arrives is variable, usually between 15 and 30 minutes after the hour. However, there are some times it doesn't arrive until 50 minutes past the hour or not even at all.

My objective is to import this data within 2 minutes of arrival, whenever that is, and then reschedule for the next hour. If the file hasn’t arrived by 50 minutes after the hour I want to send a notification to myself and the file sender that it has not arrived and then reschedule to try again the next hour.

What I haven’t been able to figure out is how to implement a 2 minute delay in a VBScript task and loop around to the beginning of the package? Does anyone have any ideas?


 
Old December 9th, 2004, 03:44 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Using Active X Scripts
1.You may want to first check if the file exists

Code:
'**********************************************************************
'  Visual Basic ActiveX Script
'************************************************************************

Function Main()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("<path to your file or server>")

If  objFile.Size >0 Then
main = DTSTaskExecResult_success
else
main = DTSTaskExecResult_failure
end if
End Function
2.On failure end task
3.On success continue with next task
4. Schedule your DTS Package accordingly.

Jaime E. Maccou
 
Old December 9th, 2004, 03:54 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response.

If I exit the package and reschedule how can I set up a time out feature when the files doesn't arrive that notifies me?

Or if I stay in the package is there a way to implement a delay before looping that doesn't consume resources?
 
Old December 9th, 2004, 05:22 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

schedule the package as a job and set the time and date intervals

Jaime E. Maccou
 
Old December 9th, 2004, 05:26 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Set up another activex script to email you on failure

Code:
'**********************************************************************
'  Visual Basic ActiveX Script
'************************************************************************

Function Main()
Dim iMsg 
 
set iMsg = CreateObject("CDO.Message")
 
Dim objMail    
Set objMail = CreateObject("CDO.Message")
 
objMail.From = "<your sqlagent email address>"
objMail.To ="<your email address>"
objMail.AddAttachment ("")
objMail.Subject="subject"
objMail.TextBody = "body"
objMail.Send
Set objMail = nothing
 
Main = DTSTaskExecResultSuccess
End Function
Jaime E. Maccou
 
Old December 13th, 2004, 11:11 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Alternatively keep an eye on the folder in question:
Using .Net

http://www.dotnetcoders.com/web/Arti...spx?article=28

Using WMI and Script

http://groups-beta.google.com/group/...3965ed1e916570

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop a select but with a delay between each try chubnut SQL Server 2005 1 June 11th, 2008 06:26 AM
delay in firing the button event - upload a file priyan.viji .NET Framework 2.0 1 February 9th, 2008 08:31 AM
loop through tables inside .mdb file using VB.NET remya1000 General .NET 3 September 24th, 2007 12:45 PM
Print directory file names in a loop ypomonh XSLT 2 May 14th, 2007 05:47 AM
Writing XML file within Loop (c#) rathbird General .NET 0 December 13th, 2004 05:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.