Translating 's/ */ /g' into T-SQL?
July 30, 2008 7:06 PM   RSS feed for this thread Subscribe

Fixing whitespace: Can someone translate 's/ */ /g' into T-SQL?

Within a field I need to contract any number of spaces above one to one. LTRIM and RTRIM aren't any use, and while I can (and, indeed, have) bodged up a bunch of nested REPLACE(field, ' ', ' ') (that should be two spaces then one - but will be squished because MeFi knows how to do this!) together, I'm hoping there's a better way, which will deal with any number of spaces, without me filling the query with a bajillion nested REPLACE functions.
posted by pompomtom to computers & internet (2 comments total)
I just found this in a google search.

http://www.itjungle.com/fhg/fhg101106-story02.html

Kind of clever and I don't see why it wouldn't work.
posted by cayla at 8:19 PM on July 30, 2008 [3 favorites has favorites]


That's genius. Ta. I knew it'd be some trick like that that I'm too dim to invent!
posted by pompomtom at 8:59 PM on July 30, 2008


« Older Where can I get the Islamic eq...   |   Can I see the new X-Files movi... Newer »
This thread is closed to new comments.