The best practice to avoid duplicates is to write
stored procedure[
^] ;)
CREATE PROCEDURE ...
@ida int = 0,
@idb int =0
AS
BEGIN
DECLARE @mda int
DECLARE @dmb int
SELECT @mda = ISNULL([IdA],0), @mdb = ISNULL([IdB],0)
FROM MYTABLE
WHERE [IdA] = @ida AND [IdB]= @idb
IF @mda=0 OR @mdb=0
BEGIN
INSERT INTO MYTABLE ([IdA],[IdB])
VALUES(@ida, @idb)
END
END