Solved

Best ways to cancel package execution

Posted on 2008-10-28
4
1,328 Views
Last Modified: 2013-11-10
I have a package that is using a Script Task to set a package variable. If the variable doesn't get a valid value (a date) is there a command to cancel the package execution?

Thanks
0
Comment
Question by:danburyit
  • 2
4 Comments
 
LVL 22

Expert Comment

by:PedroCGD
ID: 22824639
Try use DTS events inside Script to do that.
Example:
Dts.Events.FireError(-1, "", "SSIS - @LastRunDate_Dados>@StartDate! Correct the problem and try again!", "", 0)

Helped?
regards
0
 
LVL 17

Accepted Solution

by:
HoggZilla earned 125 total points
ID: 22825175
Since you are in the package running already, not really a way to "cancel" the package - but you can certainly stop it. I reccomend using the OnCompletion precedent and adding a constraint. In other words, instead of Green Arrow connecting the next task, use a "blue" onCompletion arrow. You could send the flow of the package to a MsgBox or just stop processing. You could also send it to a Script Task and Error the package.
How:
Connect the green arrow between the task that assigns the variable and the next task. Right click on the Green arrow and select Edit. This will give you the Precedence Constraint Editor - picture below.
Write an expression to evaluate the variable value. This is a powerful feature, if you need specific help please ask.
Does this help?

precedence-constraint.bmp
0
 
LVL 1

Author Closing Comment

by:danburyit
ID: 31510867
Of course! I forgot about that. Thank you!
0
 
LVL 1

Author Comment

by:danburyit
ID: 22830534
Setting the following property in the script code can determine if the precedent constraint (outlined above) will succeed or fail.

If (My code does what I want it to) Then
   Dts.Results.Success
Else
   Dts.Results.Failure
End If

If it's "Failure" then the precedent constraint will stop the package execution. Only in this case you don't need to evaluate anything in the precedent constraint. Just leave it with default value.

ConstraintDefault.png
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now