Solved

Using RTRIM doesn't work!

Posted on 2013-01-16
6
657 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

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…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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