Depends on how tightly controlled your data is. It looks as though the
first part is always the same length, and the same number of spaces
exist.
Assuming very loose control over your data:
UPDATE MyTable
SET MyField =3D LEFT(MyField, CHARINDEX(' ', MyField)) + RIGHT(MyField,
LEN(MyField) - (CHARINDEX(' ', MyField) + 1) )
WHERE CHARINDEX(' ', MyField)
This will remove one space. Run it a few times until you have none left.
On the other hand if you are certain that there are *always* 3 spaces,
then make it:
UPDATE MyTable
SET MyField =3D LEFT(MyField, CHARINDEX(' ', MyField)) + RIGHT(MyField,
LEN(MyField) - (CHARINDEX(' ', MyField) + 1) )
WHERE CHARINDEX(' ', MyField)
Run this over some test data first as I haven't tested it. I don't want
the resposability for your tables being killed. Anyway this should give
you somewhere to start. BOL has a section on String functions.
regards
David Cameron
nOw.b2b
dcameron@i...
> -----Original Message-----
> From: Bandiatmakur, Ravi [mailto:Ravi_Bandiatmakur@s...]
> Sent: Monday, 16 December 2002 5:47 PM
> To: sql language
> Subject: [sql_language] How to remove blank padded spaces inbetween
>
>
>
> Hi all...
>
> This is the data in my database.....the values containing blank spaces
> inbetween
>
> ALLTACINCORP .000000407
> ALLTACINCORP .000000408
> INTEGRITYMED .1
> ALLTACINCORP .000000409
> ALLTACINCORP .000000410
> ALLTACINCORP .000000385
> ALLTACINCORP .000000411
> ALLTACINCORP .000000412
> ALLTACINCORP .000000413
>
> What is the effecient way of removing the blank spaces in
> these values...?
> The only solution that comes to my mind is to findout the
> ascii value of
> blank space and read the string character by character
> and append it to another string if it is not a blank space.....
> Any other effecient solution will be appreciated.
>
> Thanks in advance
>
> Ravi.
>
>
>
>
> Endrum Anbudan
> Bandiatmakur Ravi
>
>
>