Thursday, February 16, 2012

Checking for file existance in DTS

I have a DTS package that extracts information and puts it in an ASCII file
for upload to our bank. The upload is done by a scheduled task. Since I
don't always know if this task is successful, (the file ascii file will be
deleted if it is), I need to check for the existance of this file at the
beginning of the DTS package to stop it from running if the file already
exists.
This is on SQL2000
My questions are...
1) Is there a way to check for the existance of an ascii file on the server
from inside a DTS package, and then stop the package if it exists.
2) (alternately) Is there a way to set a DTS data transformation that
copies the data from a table into the ascii file so that it will append
rather than overwritting the ascii file.
Sorry if this is a duplicate, I think I lost a previous version of this
before it was posted.
Charlietake a look at the code below I have it in an internal package that I use in
a lot of packages so that I don't have duplicate code
FolderPath = (DTSGlobalVariables("gvFolderPath").value)
FilePath = DTSGlobalVariables("gvFilePath").value
Dim FSO
Function Main()
Set FSO = CreateObject("Scripting.FileSystemObject")
MoveFile(FSO)
Main = DTSTaskExecResult_Success
End Function
Function MoveFile(FSO)
MoveFrom = FolderPath & FilePath
If FSO.FileExists(MoveFrom) Then
DTSGlobalVariables("gvPackageError").value =0
else
DTSGlobalVariables("gvPackageError").value = 1
End If
End Function
"Charlie Chisholm" <charlie.chisholm@.goodwill-suncoast.com> wrote in message
news:bJe3e.38592$Fz.5460@.tornado.tampabay.rr.com...
>I have a DTS package that extracts information and puts it in an ASCII file
>for upload to our bank. The upload is done by a scheduled task. Since I
>don't always know if this task is successful, (the file ascii file will be
>deleted if it is), I need to check for the existance of this file at the
>beginning of the DTS package to stop it from running if the file already
>exists.
> This is on SQL2000
> My questions are...
> 1) Is there a way to check for the existance of an ascii file on the
> server from inside a DTS package, and then stop the package if it exists.
> 2) (alternately) Is there a way to set a DTS data transformation that
> copies the data from a table into the ascii file so that it will append
> rather than overwritting the ascii file.
> Sorry if this is a duplicate, I think I lost a previous version of this
> before it was posted.
> Charlie
>

No comments:

Post a Comment