A variable can only hold one result so all this:
DECLARE @N VARCHAR(MAX)
SELECT @N = [Name] FROM [dbo].[database_tags]
Is returning is the Name from the first row it encounters. So you need to do something like this (not tested at all just off the top of my head)
SELECT @XML = REPLACE(@XML,
Name,
'<a href="<a href="pagename.aspx?tag='+Name+'">'+Name+'</a>')
FROM
dbo.database_tags
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question