SQL Server: Script to Remove Extra Spaces from a String

In this post, I am sharing one solution to remove extra spaces from a string value of SQL Server.

Before a few days ago, I was doing data migration from a CSV sources to a SQL Server Table. After that, I have checked my destination table and found lots of extra space in one of my string column.

Using this script we can remove all unwanted spaces from a string of SQL Server.

First, Create sample table and data:

Script to SELECT string without Extra Spaces:

The Result:

SQL Server Remove Extra Space From String

Script to Remove or UPDATE original string without Extra Spaces:

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com

Leave a Reply

Be the First to Comment!

Notify of