Home Forums Programming General Call sp from a Case statement RE: Call sp from a Case statement

  • Hi, Many thanks for your reply. What I'm trying to do is running a script/code which I put in a ‘Stored Procedure’ after the other two jobs have completed successfully

    This is the stored procedure, which delete all records from the table and then insert the most recent information in the table

    AS
    DELETE FROM [Imart].[ChurnRate]
    INSERT INTO [Imart].[ChurnRate]
    SELECT
        BASE.SUBS_WEEK_AND_YEAR, DAY_ID, DATE, CHURN.BB_PACKAGE ,CHURN.DTH_CUSTOMER_TYPE, CURRWK, LASTWK, TOTAL_CHURN    
    FROM
    (select
        subs_week_and_Year, Day_ID, cast(CALENDAR_DATE as date) date, BB_PACKAGE_DESC, sum(CURR_WEEK) currwk, sum(LAST_WEEK) LASTWK,DTH_CUSTOMER_TYPE
    from dbo.Base
    group by
        subs_week_and_Year, Day_ID, cast(CALENDAR_DATE as date), BB_PACKAGE_DESC, DTH_CUSTOMER_TYPE
    ) BASE
    left JOIN
    (SELECT
        SUBS_WEEK_AND_YEAR, BB_PACKAGE, DTH_CUSTOMER_TYPE, SUM(TOTAL_RECORDS) TOTAL_CHURN
    FROM Imart.BB_Churn
    GROUP BY
        SUBS_WEEK_AND_YEAR, BB_PACKAGE, DTH_CUSTOMER_TYPE
    ) CHURN ON CHURN.SUBS_WEEK_AND_YEAR = BASE.SUBS_WEEK_AND_YEAR
            AND CHURN.BB_PACKAGE = BASE.BB_PACKAGE_DESC
            and churn.DTH_CUSTOMER_TYPE = base.DTH_CUSTOMER_TYPE
    ORDER BY
    BASE.subs_week_and_Year ASC
    ;

    Again, many thanks for the help.

    All help and Any help is appreciated