Here is a quick and easy way to remove multiple whitespaces from a string, leaving only one space character between tokens.
CREATE FUNCTION dbo.CleanString (@string VARCHAR(50)) RETURNS VARCHAR(50) AS BEGIN SET @string = Ltrim(Rtrim(@string)) WHILE Charindex(' ',@string) > 1 SET @string = Replace(@string,' ',' ') RETURN @string END
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
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.