Using RTRIM doesn't work!

Hi ,

I simply want to remove a blank space in front of the text (nvarchar) from a list of values in an SQL server 2008 table but it doesn't work, I tried:

UPDATE table01
set field01 = LTRIM(field01).

What am I doing wrong??

Who is Participating?
AnujConnect With a Mentor SQL Server DBACommented:
It may have any carriage return or tab values like CHAR(10) or CHAR(9), try using replace.

 SET Field01=  LTRIM(REPLACE(REPLACE(Field01,CHAR(10),'')),CHAR(9),''))
Lee SavidgeCommented:
There is nothign wrong with this syntax:

UPDATE table01
set field01 = LTRIM(field01)

Verify the datatype of field01
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
are you sure they are the blank spaces.
run a select statement

select field01, ascii(left(filed01,1) )
from your table

check the ascii value table (google) and see it is blank
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

mbs2000Author Commented:
Thanks for the feedback, I ran  select field01, ascii(left(filed01,1) ) and it return 160 against all those which look like they have a space. 160= lowercase p and if I can the table there definately isn't a lowercase p at the start of each. I've try update and replace to change 'p' to ' ' but it doesn't work.

Any other ideas?
Aneesh RetnakaranDatabase AdministratorCommented:
you should use this  

replace (field01, char(160), '' )
Anthony PerkinsCommented:
>>160= lowercase p <<
Actually no.  lowercase P is 112.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.