• You got it !! A+ 😀

    A good practice is to define a variable (I always use @rc.) and set it to the value of @@ROWCOUNT after any event that you want to test for results. This allows for intermediate statements without losing the value originally trapped by @@ROWCOUNT.

    -- Update the row if it exists.

    Update dbo.fm_Company SET company_name=@cname, company_legal_name=@legal, company_tax_id=@taxid

    Where company_id=@INCMP;

    SET @rc = @@ROWCOUNT

    SET @CMP = @INCMP;

    -- Insert the row if the UPDATE statement failed.

    IF (@RC = 0) -- @rc didn't get reset when @@ROWCOUNT did

    BEGIN

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills