August 9, 2004 at 10:54 am
I have a dts package that needs to run once the input file has been updated. The update time fluctuates. Is there a way to have the DTS fail until the file has been updated? Possible after the Date Modified field has been updated? Or possible contents of the file not updated?
August 9, 2004 at 11:08 am
You'd need to code something in the DTS package to look for the change in the file.
August 9, 2004 at 11:14 am
Can you give me some more clues as I am a newbie
August 10, 2004 at 5:32 am
We use DOS command shell to issue DIR command for the file name and parse the results. In our case we look for the file. When found, it's time to process it. Once processed we delete the file, thus setting up for the next run.
If the file is always there, you could use a similar approach where you use the DIR command and parse out the date/time stamp, comparing to a saved value.
August 10, 2004 at 6:11 am
He is a good article on this subject.
http://:www.databasejournal.com/features/mssql/article.php/3319261
August 10, 2004 at 6:34 am
Harold, For some reason the link you sent me is not working. Is there another one?
August 10, 2004 at 7:27 am
If you have the option - VB.Net can use the FileSystemWatcher to monitor a directory for file activity. I have used this and it works just fine (you can watch for new or updated files by extention).
August 10, 2004 at 8:53 am
I believe the link had an extra colon... try this:
http://www.databasejournal.com/features/mssql/article.php/3319261
August 10, 2004 at 9:33 am
The Link worked. I will try to get it to work with this info. If anyone else has any other thoughts please post. Thansk To All.. TS
August 10, 2004 at 12:00 pm
If you have a datetime field in the dataset you are updating, you can do a query to the table and check for today's date using an execute SQL task. Then based on the result you can either fail the package or continue processing.
August 10, 2004 at 3:13 pm
Rather than fail the package, I would use the file scripting object to get the file you want and then examine it's last modified property. If it's within the range you want, you would enable the subsequent step, but if it's not, you would DISABLE the subsequent step. It's more elegant in as much as the DTS package doesn't fail, unless you want the mail message.
When it succeeds you can have an email as part of the step to let you know it's done.
Unfortunately I'm traveling and can't get you a code sample, but if this sounds like something you want to do, let me know, and I'll provide a code sample in the next day or two.
August 11, 2004 at 5:28 am
Yes I do have a datetime field in my Dataset. Another choice. Do you have any sample sql that does that?? TS
August 12, 2004 at 9:48 am
I would do something similar to the following:
Function Main()
Dim fso, file
Dim pkg, stpNext
Set pkg=DTSGlobalVariables.Parent
Set stpNext=pkg.Steps("<<Name of next DTS Step>>")
Set fso=CreateObject("Scripting.FileSystemObject")
Set file=fso.GetFile("<<FileName>>")
If file.DateModified (Your logic here) then
--If you want it to stop
stpNext.DisableStep=True
Else
--If you want it to go
stpNext.DisableStep=False
End If
Main = DTSTaskExecResult_Success
Set stpNext=Nothing
Set pkg=Nothing
Set file=Nothing
Set fso=Nothing
End Function
This has the advantage that the package won't fail, so this logic fail doesn't get caught up with a real fail. It elegantly brings the pkg to a halt.
Note, I don't exactly do this, so you may need to tweak the code, but this should be close to what you need.
August 12, 2004 at 11:09 am
Thanks!! I have a hot project that I need to finish. I will probably get hot and heavy in to this early next week. Thanks for the code.
August 12, 2004 at 11:31 am
You're welcome.
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply