Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Let's replace the unwanted spaces

Author  Topic 

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-29 : 10:16:25
I often needed this while doing data migration from a legacy system...
declare @sampleColumn varchar(255)
set @sampleColumn = 'Let''s replace the unwanted spaces!'

--select @sampleColumn
--union
select replace(replace(replace(@sampleColumn,' ','~# '),' ~#',''),'~#','')



No, you're never too old to Yak'n'Roll if you're too young to die.

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-06-29 : 11:03:10
It's been done...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=39370
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56195
and
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61794 (kindof)



Corey

I Has Returned!!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-29 : 11:12:55
quote:
Originally posted by Seventhnight

It's been done...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=39370
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56195
and
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61794 (kindof)



Corey

I Has Returned!!


Oh! Then I have reinvented the wheel


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-06-29 : 11:16:01
quote:
Originally posted by webfred

Oh! Then I have reinvented the wheel


No, you're never too old to Yak'n'Roll if you're too young to die.



No worries... I do it all the time. Often on purpose. How else am I supposed to learn.

Corey

I Has Returned!!
Go to Top of Page
   

- Advertisement -