• You should always be OK truncating a target staging table at any time. That is what staging tables are for.

    It sounds like you should create a staging table on your target database and truncate it instead of the table you are currently truncating. Then, after you have run your data flow, if your proc returned 0 rows you can skip the step that would truncate the target table and load it from your staging table using an INSERT...SELECT.

    As for how you can tell how many rows your stored procedure returned, use a Row Count Transformation in your Data Flow.

    So, here is the rundown:

    1. Execute Sql Task truncates staging table on target system.

    2. Data Flow sources data from stored procedure, captured row count in a variable, and loads staging table on target system.

    3. Precedence Constraint on line between Data Flow and another Execute Sql Task only allows execution if variable with row count is greater than 0.

    4. If row count greater than 0, Execute Sql Task runs TRUNCATE TABLE to clear target table, then INSERT...SELECT to load target table from staging table. Both statements should be done in a transaction to ensure if the INSERT...SELECT fails that the TRUNCATE is rolled back and the target table retains its data while you troubleshoot.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato