How to perform string html encode in t-sql
If you ever store HTML or XML text in SQL Table ? Then in many scenarios you need to encode string before storing to database so when you display that text in browser it shows up correctly. Here is small snippet which can easily encode string using simple T-SQL technique.
SELECT FIELD_NAME ,(SELECT FIELD_NAME AS [text()] FOR XML PATH('')) AS FIELD_NAME_HtmlENcoded FROM (SELECT '<HTML>Joe''s Pizza</HTML>' as FIELD_NAME ) TABLE_NAME
Leave a Reply
You must be logged in to post a comment.