• I figured it out...works like a charm

    SET XACT_ABORT ON;

    BEGIN TRY

    -- refresh the stored procedure

    BEGIN TRANSACTION;

    -- refresh the proc/view/function

    EXEC sp_refreshsqlmodule @spname

    COMMIT TRANSACTION;

    END TRY

    BEGIN CATCH

    IF (XACT_STATE()) = -1

    BEGIN

    PRINT 'Validation failed for : Type ' +

    @type + ', Name: ' + @spname + ', Error:' + ERROR_MESSAGE()

    ROLLBACK TRANSACTION;

    END;

    END CATCH