Ask Your Question
4

How can non-alphanumeric characters be removed from T-SQL?

asked 2022-08-30 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-07-26 01:00:00 +0000

devzero gravatar image

Non-alphanumeric characters can be removed from T-SQL using the REPLACE function. This function replaces all occurrences of a specified string or character within another string with a new string. Here's an example:

SELECT REPLACE('Hello World!#@', '#', '')

This will replace the "#" character with an empty string and return the result as "Hello World!". You can use this function repeatedly to replace all non-alphanumeric characters with an empty string:

SELECT REPLACE(REPLACE('Hello World!#@', '#', ''), '@', '')

This will remove both "#" and "@" characters, and return "Hello World!".

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-08-30 11:00:00 +0000

Seen: 15 times

Last updated: Jul 26 '21