Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
pvccaz
Yak Posting Veteran
87 Posts |
Posted - 2011-05-23 : 15:09:48
|
Hi,Is there a SQL function that i can use to URL encode a value?Thanks |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-05-23 : 15:20:22
|
Not built-in. You could try converting a varchar URL to XML, then back to varchar, but it does HTML/XML encoding, and may not do URL encoding 100%. |
|
|
pvccaz
Yak Posting Veteran
87 Posts |
Posted - 2011-05-23 : 16:15:28
|
ok. I am searching for some samples in google. I was wondering if there is one in sqlteam.com that i could refer to. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-05-23 : 16:21:03
|
I don't know of one offhand, but "URL encode" in the forum search at the top of the page would be the best start.It's easy enough to test:SELECT CONVERT(varchar(1000), CONVERT(xml, 'http://www.sqlteam.com/'))The problem occurs with URLs that are already encoded, like "http://www.sqlteam.com/something%20with%20spaces", as the % symbols will get converted separately, and may not reconstitute as a workable URL. |
|
|
pvccaz
Yak Posting Veteran
87 Posts |
Posted - 2011-05-23 : 17:03:15
|
Thanks. I saw the below one. I am testing it and looks like it is working good.http://www.sqlservercentral.com/scripts/URL/62679/ |
|
|
|
|
|