SQL Server Performance

Replace & with simple &

Discussion in 'SQL Server 2005 General Developer Questions' started by lucutus, Dec 13, 2007.

  1. lucutus New Member

    Hello All,
    Im trying to do the somthing like this to output a Link in XML Format:
    SELECT 'http://mysite.com/Hotels?'+HotelID+'&LanguageID'+@Lang
    FROM HotelTable
    FOR XML ...
    But i always get the & replaced with & - this wont work for my web server...
    any ideas?
    I tried char(38), replace(x,&amp,&) ...


  2. FrankKalis Moderator

    I don't think you can stop SQL Server from automatically replace & with & when you use FOR XML as this seems to be required for valid XML. Can't you use some client component to strip off these characters before they are passed to the webserver?
  3. lucutus New Member

    Well, the requirement of escaped & in XML resolved my problems because I am using the resulting XML as a Google Sitemap.
    The Links inside are not cliccable directly (for testing), but will work just fine for a Sitemap.
    Finally this example demonstrates Links with & instead of &:
    https://www.google.com/webmasters/tools/docs/en/protocol.html#sitemapXMLExample
    greetz, lucutus

Share This Page