The following is the select statement that returns all the URL's containing a %20 (space) at the end of it:
select * from Table1 where Column1 like '%%20'
How can the '%20' be removed from all these URLs using SQL?
Edit 1:
Is there a way to remove '%20' only if it is found in the end of the URL (saving all other instances on '%20' in the URL)?
We can remove part of the string using REPLACE() function. We can use this function if we know the exact character of the string to remove. REMOVE(): This function replaces all occurrences of a substring within a new substring.
The SUBSTRING() function extracts some characters from a string.
The REPLACE() function replaces all occurrences of a substring within a string, with a new substring. Note: The search is case-insensitive.
Below is the syntax for the SUBSTRING() function to delete the last N characters from the field. Syntax: SELECT SUBSTRING(column_name,1,length(column_name)-N) FROM table_name; Example: Delete the last 2 characters from the FIRSTNAME column from the geeksforgeeks table.
This is simple. I assume that you are using Microsoft SQL Server. Try the following:
Select SUBSTRING(Column1, 0, Len(Column1) - 2) As Column1, Column2
From Table1 where Column1 like '%[%]20'
In above, I've selected Column1 and %20 will be removed from the end of Column1 and selected Column2 as well. You can select all your columns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With