0 votes
1 view
in SQL by (20.3k points)

What is the best way to remove all spaces from a string in SQL Server 2008?

LTRIM(RTRIM('  a b ')) would remove all spaces at the right and left of the string, but I also need to remove the space in the middle.

1 Answer

0 votes
by (101k points)

You can use REPLACE() function to remove the spaces in the entire column or a string. Not only spaces, but you can also replace any character with another character. Here is the SQL query to remove all spaces from a string in SQL Server:

SELECT REPLACE(Column_Name, ' ', '')

I recommend checking out this SQL Tutorial to learn more about REPLACE() function.

Related questions

0 votes
1 answer
+3 votes
3 answers
asked May 28, 2019 in Python by Anvi (10.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...