Translating 's/ */ /g' into T-SQL?
July 30, 2008 7:06 PM   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 answers total) 1 user marked this as a favorite
Best answer: I just found this in a google search.

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]

Response by poster: 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 equivalent of Jewish...   |   Can I see the new X-Files movie and then watch the... Newer »
This thread is closed to new comments.