You should be able to use a correlated subquery, like so:
SELECT
@mystring,
REPLACE(@mystring, name, value) AS newstring
FROM (
SELECT TOP (1) * FROM @tab WHERE @mystring LIKE '%' + name + '%' ORDER BY LEN(name) DESC
) AS correlated
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.