Home Forums SQL Server 2005 Business Intelligence If count of records in query >0, proceed, else stop SSIS task and email RE: If count of records in query >0, proceed, else stop SSIS task and email

  • Hi There

    Simplest for me would be the following:

    Create a variable and populate the result to that variable

    a) Right click on your control flow surface and select "Variables"

    b) Create a "global variable" called accessCount (int)

    c) On your ExecuteSQL task double click and under "General/Result set" select "Single Row"

    d) Under "Result Set" tab click "Add"

    e) Set "Result Name" to the name of the field that has the result you are looking for. Click the variables drop down and select "user::accessCount"

    Let's presume that you will route to a data flow task to load data and to an email if there is no data.

    a) Drag successful precedent (green) from the executeSQLtask to the data flow task

    b) Right click the precedent and select "Edit"

    c) Under "Evaluation Option" select "Expression and Constraint"

    d) Leave "Value" as "Success"

    e) Under "Expression" type @accessCount > 0 (Click "Test" to make sure everything is working)

    Email

    Repeat above b), c) & d). on e) Enter the following expression @accessCount == 0

    Thus, if you have data you will process it and if you do not you will fire off an email to someone to let them know.

    SSIS can seem cumbersome but once you get into it; it really becomes a powerful tool.

    Hope this helps! 🙂

    [font="Arial Narrow"]MCITP Sql Server 2008: Business Intelligence. 4 Years +
    Jason Vollaire[/font]