Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove blanks from a string

Status
Not open for further replies.

3270

Programmer
Sep 8, 2005
11
DK
Hi

whats the easy way to remove blanks from the at string?
If i got a string like this 'xxx yyy z zz' and i want it to look like this 'xxxyyyzzz' is there then a simple solution?

example thats doesnt work:

declare @String varchar(20)

select @string = 'xxx yyy z zz'

select @string = replace(@string ,' ','')



 
On a Sql 2000 server in 6.5 mode and @@options = 0
 
When i use the replace proecdure nothing happends, the ouput is 'xxx yyy z zz'
if i write select @string = replace(@string ,' ','*')

the output is 'xxx*yyy*z*zz'

 
select @string = replace(replace(@string ,' ','*'),'*','') doesnt work for me either.

if my statements is like this
select @string = 'aaaxxyyy'
select @string = replace(@string,'x','')
the result is : 'aaa yyy'

 
The idea of an "empty string" was introducted in MS-SQL 7.0, there isn't such a thing as an "empty string" in MS-SQL 6.5.
which is what you are trying to do.

try the following. probably wont work either, and may even give an error.

select @string = replace(@string ,' ',space(0))




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
select @string = replace(@string ,' ',space(0))
returns null.

I guess there is no easy solution then.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top