Example:
Lopez, Michelle MD
Spanish
You might want to just try replacing:
set @locAnchor = ('' +
@locTitle + '');
with:
SELECT @locAnchor = (SELECT 'theloc.aspx?id=' + @locID AS 'Value6/a/@href',
@locTitle AS 'Value6/a/@title',
@locTitle AS 'Value6/a'
FOR XML PATH (''))
instead of trying to dynamically create the XML