TSQL - How to URL Encode

前端 未结 5 1918
清酒与你
清酒与你 2021-02-13 11:22

Looking for a bug free tested sql script that i could use in a UDF to encode a url through sql. Function would take in a URL and pass out a URL Encoded URL. I have seen a few,

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-13 11:42

    Personally I would do this in the application rather than the DB - but if you have to for some reason and you can enable CLR Integration then this would be a perfect candidate for a CLR UDF. It'd be simpler than trying to do it in SQL and probably more reliable and performant too.

    There are INET_URIEncode and INET_URIDecode functions in the free version of the SQLsharp T-SQL CLR extension library. It handles Unicode too, though you need the paid version to handle non-standard %uXXYY encoding.

提交回复
热议问题