• First things first, how many rows does this return?

    SELECT EMPL_UNO, MONTH, PERIOD, BILLABLE_HRS, NONBILL_HRS, ACCOUNTABLE_HRS,

    BILLABLE_AMT, NONBILL_AMT, ACCOUNTABLE_AMT, RECEIPT_AMT, LAST_MODIFIED

    FROM _TBM_Persnl_Bud_Update;

    If it's 0, then that's your problem as it is what your CURSOR is looping over.

    Secondly, why are you using a CURSOR? A CURSOR in this case makes kittens cry :crying: and puppies run away.

    Could we look at making it more set-based instead? This is completely untested as you haven't supplied DDL, sample data or expected results. Test it thoroughly before use.

    ALTER PROCEDURE [dbo].[HM_Annual_Budget_Import] /*Stored Procedure*/

    AS

    BEGIN

    SELECT @ROW_UNO = lastkey + 1

    FROM cms_unique_keys

    WHERE tbname = 'tbm_persnl_bud';

    MERGE INTO tbm_persnl_bud tbl

    USING (SELECT (ROW_NUMBER() OVER(PARTITION BY EMPL_UNO, MONTH ORDER BY (SELECT NULL))-1)+newKey,

    EMPL_UNO, MONTH, PERIOD, BILLABLE_HRS, NONBILL_HRS, ACCOUNTABLE_HRS,

    BILLABLE_AMT, NONBILL_AMT, ACCOUNTABLE_AMT, RECEIPT_AMT, LAST_MODIFIED

    FROM _TBM_Persnl_Bud_Update

    CROSS APPLY (SELECT lastkey + 1 AS newKey

    FROM cms_unique_keys

    WHERE tbname = 'tbm_persnl_bud') b

    ) correctValues ON (tbl.empl_uno=correctValues.EMPL_UNO AND tbl.month = correctValues.MONTH)

    WHEN NOT MATCHED BY TARGET THEN

    INSERT (ROW_UNO, EMPL_UNO, MONTH, PERIOD, BILLABLE_HRS, NONBILL_HRS, ACCOUNTABLE_HRS,

    BILLABLE_AMT, NONBILL_AMT, ACCOUNTABLE_AMT, RECEIPT_AMT, LAST_MODIFIED)

    VALUES (correctValues.newKey, correctValues.EMPL_UNO, correctValues.MONTH, correctValues.PERIOD,

    correctValues.BILLABLE_HRS, correctValues.NONBILL_HRS, correctValues.ACCOUNTABLE_HRS,

    correctValues.BILLABLE_AMT, correctValues.NONBILL_AMT, correctValues.ACCOUNTABLE_AMT,

    correctValues.RECEIPT_AMT, correctValues.LAST_MODIFIED);

    SET @ROW_UNO = @ROW_UNO + (CASE WHEN @@ROWCOUNT <> 0 THEN @@ROWCOUNT-1 ELSE 0 END);

    UPDATE CMS_UNIQUE_KEYS

    SET lastkey = @ROW_UNO

    WHERE tbname = 'tbm_persnl_bud';

    END


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/