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:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of