Expression based on a variables value - basic rowcount question really

  • sorry to post such a simple question, but am getting no where slowly

    consider the following code

    DECLARE @count int

    select @count = [MBFREE] from TblTest

    WHERE drive = 'T'

    what I want to happen is for an email to fire if @count < 2000 else nothing to happen

    I have the above in an Execute SQL task (first step) and have a second step being an SMTP email waiting to fire, but unsure how to connect 1 to 2 correctly. I would have thought the simplest would be a precedence constraint. But am having trouble lining up the variable @count to the constraint.

    Does this make sense ? oh dear.

  • hi,

    Add a script component and use the variable rowcount in the script component.Then using the conditional split transformation you can split it up based on the required condition.

    Thanks

    vijay

  • Dancewav,

    I would use a condition on the precedence constraint (or as I call it an expression on the green line) between the execute SQL task and the email task.

    1.So drag the green line from execute SQL task to Send Mail task.

    2.On the properties for the constraint – change EvalOp to ExpressionAndConstraint

    3.Two properties down from EvalOp is the Expression property – change this to (@var_table_exists>=2000) ==1

    Then it should only fire on the variable matching or exceeding 2000

    Hope this helps.

    Mark Elleray

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply