Hi everyone,
I have a SQL table in which there is a name column. I found these 3 names which contains "single quote" but all 3 are different types of "single quotes".
I am using replace function to remove this quoute but its only removing it from the last name.
How can I remove it from all 3 names?
Mus’ab
‘ABD ALRAHMAN
SA'D
They are different characters and therefore multiple nested REPLACE commands would be required.
DECLARE @x VARCHAR(50) = CONCAT ('Some''', CHAR (96), CHAR (145), CHAR (146));
SELECT @x
,REPLACE (REPLACE (REPLACE (REPLACE (@x, '''', ''), CHAR (96), ''), CHAR (145), ''), CHAR (146), '');
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
May 17, 2023 at 12:15 pm
They are different characters and therefore multiple nested REPLACE commands would be required.
DECLARE @x VARCHAR(50) = CONCAT ('Some''', CHAR (96), CHAR (145), CHAR (146));
SELECT @x
,REPLACE (REPLACE (REPLACE (REPLACE (@x, '''', ''), CHAR (96), ''), CHAR (145), ''), CHAR (146), '');
Thank you very much sir.
May 17, 2023 at 1:35 pm
To figure out which CHAR s are in the string ... check this thread https://www.sqlservercentral.com/forums/topic/how-to-remove-special-chars#post-4157818
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
May 17, 2023 at 1:43 pm
but this leads to the question - why do you need to remove them? they are valid characters and if the output is being displayed anywhere for users removing those is a big issue as you are CHANGING what the name of the individuals is.
what should be done if nothing else is replacing the "smart quote", normally used by Word and similar word processing applications with the correct apostrophe.
May 18, 2023 at 4:16 am
but this leads to the question - why do you need to remove them? they are valid characters and if the output is being displayed anywhere for users removing those is a big issue as you are CHANGING what the name of the individuals is.
what should be done if nothing else is replacing the "smart quote", normally used by Word and similar word processing applications with the correct apostrophe.
Requirement of client. They asked to deliver it in this format. It is their problem if name of individual is changed. We just have to apply these changes.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply