I have the following code in sql server. I need to make it in the first if it exits and execute the same statement that is inside the else tag so as not to repeat the code it has in there. How do I do this?
DECLARE @AG_NUM varchar(15)
DECLARE @BCO_NUM VARCHAR(3)
DECLARE @AG_NUM1 varchar(15)
DECLARE @BCO_NUM1 VARCHAR(3)
SELECT TOP 1 @BCO_NUM1 = BcoNUm, @AG_NUM1 = AgNum FROM CONTA_FIN WHERE ContaFinCCorNum = '{AgNum}'
SELECT @AG_NUM = AgNum, @BCO_NUM = BcoNum FROM DUPLICATA where DupNum = '{Duplicata}'
IF (@BCO_NUM is null) OR (@AG_NUM is null)
BEGIN
UPDATE DUPLICATA SET BcoNum = @BCO_NUM1, AgNUm = @AG_NUM1 WHERE DupNum = '{Duplicata}'
UPDATE PARC_DOC_FIN SET BcoNum = @BCO_NUM1, AgNum = @AG_NUM1 WHERE ParcDocFinDupNum = '{Duplicata}'
END
ELSE
-- RESTO DO CODIGO
END.