Quote:
SQL 2k, sp4a (the latest sp)
Is there a way to do a conditional step in DTS, like there is in SQL 2005?
Basically I have a DTS package that does several steps, and unzipping a file
is one of them. *Our customer sometimes sends us files that are not zipped,
so I'd like to skip a few steps as they are not needed. *Is there an easy
way to achieve this? |
You can use ActiveX Script task to list files in a directory and set
its execution result to success or failure depending on the results of
finding the *.zip file; then split your execution (using workflow
green and red arrows) in two "tails" with different tasks.
Check google (http://www.tek-tips.com/viewthread.cfm?
qid=1267900&page=5) to find example on how to script if a file exists
or not. Use in an IF construct with Main = DTSTaskExecResult_Success
or the corresponing for Error/Failure. Then attach different tasks
depending on the result.
Another way can be involving a BATCH script, like:
IF EXIST C:\..path..\yourfile.zip GOTO SUCCESS
exit 1
:SUCCESS
exit 0
Create a file, let's say CheckIfZipped.bat, call this from inside an
Execute Process Task and behave like the example above using workflow
for different results.
If you need to do this for an always different file name, assuming you
know the name of this file as DTS execution starts (ie, it is in a
global variable) substitute yourfile.zip with %1 inside the batch and
build dynamically (with Dynamic Properties Task) the
ProcessCommandLine of the ExecuteProcess Task.
HTH,
M.
> Thanks, Andre