Answered by:
Removing spaces between words in sql

Question
-
I guess there is no built in functions to do this but I have a function that replaces anything that is not A-Z with a space and returns @data. What I additionally need the function to do is scrunch up @data (remove all blanks betwwen each word so that 'I ran very fast' would be 'Iranveryfast').
What I need help in doing is the "Scrunch" part. Is there a way I could move the @Data to something like @DataHold and inspect each character, if it is not a blank, move that character back to @Data?
This was pretty easy for me to do in C# with a while loop, but I do not know how to get it done in SQL Server 2005.Thanks for any help!
Tuesday, March 20, 2007 4:45 PM
Answers
-
Use the replace function.
replace( @Data, ' ', '' )
For example,
DECLARE @Data varchar(1000)
SET @Data = 'I ran very fast'SELECT replace( @Data, ' ', '' )
---------------------------------
IranveryfastTuesday, March 20, 2007 6:21 PM
All replies
-
Use the replace function.
replace( @Data, ' ', '' )
For example,
DECLARE @Data varchar(1000)
SET @Data = 'I ran very fast'SELECT replace( @Data, ' ', '' )
---------------------------------
IranveryfastTuesday, March 20, 2007 6:21 PM -
@ Arnie Rowland : ur message was very much useful.. thanks...
- Edited by ManojWolver Wednesday, September 28, 2011 2:57 PM
Wednesday, September 28, 2011 2:57 PM -
Try this link also here is more possibilities http://codingresolved.com/discussion/157/how-to-trim-space-in-sql#Item_2
- Proposed as answer by Waqas Silat Thursday, October 25, 2012 8:15 PM
Thursday, October 25, 2012 8:14 PM -
thank you!Wednesday, October 2, 2019 12:45 PM