Please refer below code.
SQL
DECLARE @fruitetable AS TABLE(Id INT,Name VARCHAR(50))
INSERT INTO @fruitetable VALUES(1,'Apple')
INSERT INTO @fruitetable VALUES(1,'Apple')
INSERT INTO @fruitetable VALUES(2,'Melon')
INSERT INTO @fruitetable VALUES(3,'Chary')
INSERT INTO @fruitetable VALUES(4,'Grapes')
SELECT * FROM @fruitetable
DECLARE @Name VARCHAR(50)
DECLARE @ReplaceName VARCHAR(50)
SET @ReplaceName = 'Apple'
SET @Name = 'Orange'
UPDATE T SET Name = @Name FROM
(
SELECT ROW_NUMBER() OVER(PARTITION BY Name ORDER BY (SELECT 0)) AS RowNum ,* FROM @fruitetable
) AS T
WHERE RowNum = (SELECT MAX(RowNum) FROM (
SELECT ROW_NUMBER() OVER(PARTITION BY Name ORDER BY (SELECT 0)) AS RowNum ,* FROM @fruitetable
) as tbl
WHERE tbl.Name = @ReplaceName)
SELECT * FROM @fruitetable