How do I use the expression to force a failure using an If statement to evalute a rowcount variable?
I'd evaluate that variable in a script task instead.|||Do you have an example of how to do that?
If my rowcount < 1 then I want to fail the package
|||
Ken Augustine wrote:
Do you have an example of how to do that?
If my rowcount < 1 then I want to fail the package
Actually, use an expression. Add the script task and hook up a precedence constraint to it. Set it to evaluate the expression.
For the script code, it's basically the default code that is generated when you add a new script task. The only difference is that you call Dts.Results.Failure instead of success.
Code Snippet
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Dts.TaskResult = Dts.Results.Failure
End Sub
End Class
|||Can you help me with the if then expression to evalute the variable?
Thanks for your help.
|||
Ken Augustine wrote:
Can you help me with the if then expression to evalute the variable?
Thanks for your help.
Just use:
@.rowcount < 1
That's all you need. When you double click on the connection between the ?Data flow? and the script task, set it to use constraint and expression. Then use the above (copy and paste if your variable is named 'rowcount') in the expression box. Note that I believe the CaSE of the variable name is important.
No comments:
Post a Comment