Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using RTRIM doesn't work!

Posted on 2013-01-16
6
Medium Priority
?
707 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 1000 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 1000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

971 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