dbTalk Databases Forums  

conditional step

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss conditional step in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andre
 
Posts: n/a

Default conditional step - 06-23-2009 , 04:52 AM






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

Reply With Quote
  #2  
Old   
matteog
 
Posts: n/a

Default Re: conditional step - 06-23-2009 , 06:17 AM






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

Reply With Quote
  #3  
Old   
Tom Moreau
 
Posts: n/a

Default Re: conditional step - 06-23-2009 , 07:39 PM



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" <no (AT) spam (DOT) com> wrote

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

Reply With Quote
  #4  
Old   
Andre
 
Posts: n/a

Default Re: conditional step - 06-24-2009 , 12:33 AM



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

Reply With Quote
  #5  
Old   
Tom Moreau
 
Posts: n/a

Default Re: conditional step - 06-24-2009 , 08:31 AM



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" <andre (AT) nospam (DOT) com> wrote

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

Reply With Quote
  #6  
Old   
Andre
 
Posts: n/a

Default Re: conditional step - 06-24-2009 , 11:54 PM



I see. Thanks Tom - I appreciate the help.

Andre

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.