If rowcount = 0, email me.

  • I am sure this has been asked before.

    I am evaluating some packages...and want to have SSIS e-mail me if the rowcount of a table = 0.

    I have no idea how to go about doing this.

    Anyone done it before?

  • You bet, it's pretty simple to do.

    Set up a package-scoped variable of type Int32 to store your row count. In your data flow, drag across a row count transformation - it's a pass-through transform that will capture the count of rows sent through it, and you'll assign that row count to the variable you just created.

    Now over in your control flow, create your send mail task and configure it with the appropriate info (to addr, from addr, and the message you want to receive). Connect your data flow to this new send mail task with a precedence constraint, and double-click this constraint to open its properties. Set it to "Expression", and in your expression box you should check whether the row count equals zero. The syntax will look something like this:

    @[User::MyRowCountVariable] == 0

    hth,

    Tim

  • Thanks....Where in the data flow should I place the row count? Between the source and destination? Before the source? After the Destination?

  • Between source and destination.


  • Last question --

    Is there a way to do this without a dataflow task?

  • Yes - you can assign the result of an execute SQL task such as

    SELECT COUNT(ID) FROM TABLE

    directly to a variable.


Viewing 6 posts - 1 through 6 (of 6 total)

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