Developping for the translation industry RSS 2.0

 Tuesday, February 09, 2010

Here is a quick and easy way to remove multiple whitespaces from a string, leaving only one space character between tokens.

               (@string VARCHAR
    SET @string = Ltrim
    WHILE Charindex
('  ',@string) > 1
      SET @string = Replace
(@string,'  ',' ')
    RETURN @string


Other Posts:

How to generate random numbers with a T-SQL query

How to insert a file in an image column in SQL Server 2005

How to track the growth of your SQL Server database

SQL Server indexing best practices and guidelines

How to remove leading zeros from the results of an SQL Query

Tuesday, February 09, 2010 1:24:17 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Code Snippet | SQL

About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2019
Stanislas Biron
Sign In
Total Posts: 135
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2019, Stanislas Biron