Monday, March 12, 2012

removing spaces from an nvarchar column

Hello,
This is a simple question, hopefully with a simple answer. I have
an nvarchar column of length 255. In one of the rows I have the
following sentance - 'See the brown ball bounce'. Is it possible to
use a command to remove all of the spaces in that sentance, so that
the sentance reads 'Seethebrownballbounce'? As you can see, I am not
just interested in getting rid of the trailing and leading spaces.

Thanks,
BillyYou can use REPLACE:

SELECT REPLACE(N'See the brown ball bounce', N' ', N'')

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Billy Cormic" <billy_cormic@.hotmail.com> wrote in message
news:dd2f7565.0411021606.9bbc6d5@.posting.google.co m...
> Hello,
> This is a simple question, hopefully with a simple answer. I have
> an nvarchar column of length 255. In one of the rows I have the
> following sentance - 'See the brown ball bounce'. Is it possible to
> use a command to remove all of the spaces in that sentance, so that
> the sentance reads 'Seethebrownballbounce'? As you can see, I am not
> just interested in getting rid of the trailing and leading spaces.
> Thanks,
> Billy

No comments:

Post a Comment