SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 URL Encode via SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pvccaz
Yak Posting Veteran

USA
87 Posts

Posted - 05/23/2011 :  15:09:48  Show Profile  Reply with Quote
Hi,
Is there a SQL function that i can use to URL encode a value?
Thanks

robvolk
Most Valuable Yak

USA
15670 Posts

Posted - 05/23/2011 :  15:20:22  Show Profile  Visit robvolk's Homepage  Reply with Quote
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%.
Go to Top of Page

pvccaz
Yak Posting Veteran

USA
87 Posts

Posted - 05/23/2011 :  16:15:28  Show Profile  Reply with Quote
ok. I am searching for some samples in google. I was wondering if there is one in sqlteam.com that i could refer to.
Go to Top of Page

robvolk
Most Valuable Yak

USA
15670 Posts

Posted - 05/23/2011 :  16:21:03  Show Profile  Visit robvolk's Homepage  Reply with Quote
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.
Go to Top of Page

pvccaz
Yak Posting Veteran

USA
87 Posts

Posted - 05/23/2011 :  17:03:15  Show Profile  Reply with Quote
Thanks.
I saw the below one. I am testing it and looks like it is working good.

http://www.sqlservercentral.com/scripts/URL/62679/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000