Solved

Using RTRIM doesn't work!

Posted on 2013-01-16
6
619 Views
Last Modified: 2013-01-16
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??

Thanks,
0
Comment
Question by:mbs2000
6 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 38783570
There is nothign wrong with this syntax:

UPDATE table01
set field01 = LTRIM(field01)

Verify the datatype of field01
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 250 total points
ID: 38783572
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
0
 
LVL 15

Accepted Solution

by:
Anuj earned 250 total points
ID: 38783593
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),''))
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:mbs2000
ID: 38783656
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?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 38783672
you should use this  

replace (field01, char(160), '' )
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 38783750
>>160= lowercase p <<
Actually no.  lowercase P is 112.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now