Script of the day - Remove White Space from a String

OK - this might be stretching the "Is this Useful" question a bit, but hey, I needed it today and thought I would share it with you - it's free!  This construct takes the whitespace out of a string.

/*

usc_DBA_Remove_White_Space.sql

Removes extra white spaces between two words in a character string

*/

DECLARE @TEXT VARCHAR(100)

DECLARE @I INT

SET @TEXT = 'Buck                                                 Woody'

SET @I = CHARINDEX (' ' , @TEXT )

PRINT SUBSTRING(@TEXT,1,@i-1) + ' ' +

LTRIM(SUBSTRING(@TEXT,@I,len(@TEXT)))

Published 24 August 07 01:39 by Buck Woody

Comments

# MSDN Blog Postings » Script of the day - Remove White Space from a String said on August 24, 2007 5:44 PM:

PingBack from http://msdnrss.thecoderblogs.com/2007/08/24/script-of-the-day-remove-white-space-from-a-string/

# MSDN Blog Postings » Script of the day - Remove White Space from a String said on August 24, 2007 5:45 PM:

PingBack from http://msdnrss.thecoderblogs.com/2007/08/24/script-of-the-day-remove-white-space-from-a-string/

Anonymous comments are disabled

About Buck Woody

http://www.buckwoody.com
Page view tracker