Re: Removing multiple blanks in a string
From: Gert-Jan Strik (sorry_at_toomuchspamalready.nl)
Date: 07/23/04
- Next message: Anith Sen: "Re: Removing multiple blanks in a string"
- Previous message: PVR: "bulkadmin permission to a particular login name"
- In reply to: Jonathan Blitz: "Removing multiple blanks in a string"
- Next in thread: Roy Harvey: "Re: Removing multiple blanks in a string"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 23 Jul 2004 20:07:45 +0200
And if you can't use the method Anith suggested, then you can use this:
update #t
set col1 =
Replace(
Replace(
Replace(
Replace(
Replace(
Replace(col1, replicate('X',132),'X')
, replicate('X', 21),'X')
, replicate('X', 6),'X')
, replicate('X', 3),'X')
, replicate('X', 2),'X')
, replicate('X', 2),'X')
In this example, multiple X are replaced with a single X, and can handle
varchar(8000) (and bigger).
Hope this helps,
Gert-Jan
Jonathan Blitz wrote:
>
> We need to prevent a user entring a string with multiple blanks between
> words.
> If the user does enter more than one blank we want to reduce it to one.
>
> I tried using the replace function in an "Instead of" trigger but that only
> works but that will only remove one pair at a time so if the user enter an
> odd number of blanks or more than 2 blanks it cannot remove them.
>
> Any ideas?
>
> --
> Jonathan Blitz
> AnyKey Limited
> Israel
>
> "When things seem bad
> Don't worry and shout
> Just count up the times
> Things have worked themselves out."
-- (Please reply only to the newsgroup)
- Next message: Anith Sen: "Re: Removing multiple blanks in a string"
- Previous message: PVR: "bulkadmin permission to a particular login name"
- In reply to: Jonathan Blitz: "Removing multiple blanks in a string"
- Next in thread: Roy Harvey: "Re: Removing multiple blanks in a string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|