Hey rakibxl,
Please refer below sample.
SQL
DECLARE @FatherSonRelation AS TABLE(IDCustomerFather VARCHAR(10), IDCustomerSon VARCHAR(10))
INSERT INTO @FatherSonRelation VALUES('A','B')
DECLARE @Father VARCHAR(10)
DECLARE @Son VARCHAR(10)
SET @Father='B'
SET @Son='A'
IF EXISTS(SELECT * FROM @FatherSonRelation WHERE (IDCustomerFather=@Father AND IDCustomerSon=@son) OR (IDCustomerFather=@Son AND IDCustomerSon=@Father))
BEGIN
PRINT 'You Can not insert'
END
ELSE
BEGIN
INSERT INTO @FatherSonRelation VALUES(@Father, @Son)
SELECT * FROM @FatherSonRelation
END