Encode html in sql server
It's a bit late, but anyway, here the proper ways: HTML-Encode (HTML encoding = XML encoding):
HTML-encode in a query:
HTML-Decode:
If you want to do it properly, you can use a CLR-stored procedure. Fortunately, you can rip System.Web.HttpUtility out of the mono sourcecode (.NET for Linux). Then you can use HttpUtility without referencing system.web. Then you write this CLR-Stored-Procedure:
And register it:
Afterwards, you can use it like normal functions:
Anybody who just copy-pastes, please note that for efficiency reasons, you would use
if you'd use this function in production. See here for the edited mono classes: You need to define NET_2_0 in the build options |