CREATE PROC [dbo].[CopyCoFamilyCode]
    @SlaveCode VARCHAR(15),
    @MasterCode VARCHAR(15)
AS
INSERT INTO CoFamilyCode
(
    GoodsCode,
    InsuranceType,
    GenericCode
)
SELECT @SlaveCode,
       co.InsuranceType,
       co.GenericCode
FROM CoFamilyCode co
WHERE co.GoodsCode = @MasterCode
      AND NOT EXISTS
(
    SELECT GoodsCode
    FROM CoFamilyCode cof
    WHERE cof.GoodsCode = @SlaveCode
          AND cof.GenericCode = co.GenericCode
          AND cof.InsuranceType = co.InsuranceType
);
RETURN @@ROWCOUNT;