Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using RTRIM doesn't work!

Posted on 2013-01-16
6
Medium Priority
?
691 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 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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