Search code examples
sqlemailhyperlinkhref

Send SQL Email (href with colum)


I want to link the word Click with URL in the email. This URL change for every row of SELECT.

I write this:

td = CAST('<a href="'+REPLACE('http://asñdjas/asdas/sadas.aspx?lng=&orig=&guid={ID}','{ID}',T.projectId)+'">Click</a>' AS XML), ''

But SQL server return:

Análisis de XML: línea 1, carácter 73; se esperaba punto y coma

Which translates to

XML parsing : line 1 , character 73; expected semicolon


Solution

  • The & symbol should be encoded as &amp;. The parser sees &orig and expects a semicolon after it (or at least at some point in the string).