Discussion:
conditional step
(too old to reply)
Andre
2009-06-23 09:52:15 UTC
Permalink
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?

Thanks, Andre
matteog
2009-06-23 11:17:29 UTC
Permalink
Post by Andre
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.
Post by Andre
Thanks, Andre
Tom Moreau
2009-06-24 00:39:08 UTC
Permalink
In an ActiveX task, you can have it make its decision and have the result
either success or failure accordingly. You then have one workflow for
success and the other for failure.
--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau


"Andre" <***@spam.com> wrote in message news:uNEsxg%***@TK2MSFTNGP02.phx.gbl...
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?

Thanks, Andre
Andre
2009-06-24 05:33:44 UTC
Permalink
I currently have ActiveX steps that copy the file and then unzip it. Are
you saying I do a test to see if it ends in .zip and if so I call the unzip
ActiveX step, and if not I call the import step?

Andre
Tom Moreau
2009-06-24 13:31:33 UTC
Permalink
Essentially, yes. The ActiveX script would check for the .zip extension.
If true, then succeed, else fail. The success workflow would then unzip.
--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau


"Andre" <***@nospam.com> wrote in message news:616663D0-92F1-4655-B230-***@microsoft.com...
I currently have ActiveX steps that copy the file and then unzip it. Are
you saying I do a test to see if it ends in .zip and if so I call the unzip
ActiveX step, and if not I call the import step?

Andre
Andre
2009-06-25 04:54:35 UTC
Permalink
I see. Thanks Tom - I appreciate the help.

Andre

Continue reading on narkive:
Loading...