Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 832525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:22:32+00:00 2026-05-15T04:22:32+00:00

Looking for a bug free tested sql script that i could use in a

  • 0

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, but all i have come across seem to have some flaws.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:22:33+00:00Added an answer on May 15, 2026 at 4:22 am

    In order to use this script, you’ll want to use Numbers table.

    CREATE FUNCTION [dbo].[URLEncode] 
        (@decodedString VARCHAR(4000))
    RETURNS VARCHAR(4000)
    AS
    BEGIN
    /******
    *       select dbo.URLEncode('K8%/fwO3L mEQ*.}')
    **/
    
    DECLARE @encodedString VARCHAR(4000)
    
    IF @decodedString LIKE '%[^a-zA-Z0-9*-.!_]%' ESCAPE '!'
    BEGIN
        SELECT @encodedString = REPLACE(
                                        COALESCE(@encodedString, @decodedString),
                                        SUBSTRING(@decodedString,num,1),
                                        '%' + SUBSTRING(master.dbo.fn_varbintohexstr(CONVERT(VARBINARY(1),ASCII(SUBSTRING(@decodedString,num,1)))),3,3))
        FROM dbo.numbers 
        WHERE num BETWEEN 1 AND LEN(@decodedString) AND SUBSTRING(@decodedString,num,1) like '[^a-zA-Z0-9*-.!_]' ESCAPE '!'
    END
    ELSE
    BEGIN
        SELECT @encodedString = @decodedString 
    END
    
    RETURN @encodedString
    
    END
    GO
    

    The script is fully available on SQL Server Central (registration required)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a multithreaded Java application, I just tracked down a strange-looking bug, realizing that
Just now I'm looking at fixing a localization bug with a small application that
Clarification/summary for the question -- we're looking for: a hosted bug tracking system, that
Short: I am looking for a very simple (configuration/maintenance wise) solution, that would allow
i'm looking for an app for our small office that would be used as
I'm looking for a free bug tracking software (hosted preferably, as my host doesn't
I am looking for a free tool that allows re-arranging pages of a PDF
I am looking at a bug in WebSVN where when I get into a
I've been looking into some bug trackers and Retrospectiva seems like a good tool.
I'm looking for a library that will allow me to programatically modify Excel files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.