Solved

LTrim in SQL Server not working

Posted on 2009-05-15
10
819 Views
Last Modified: 2012-05-07
Hello experts,
I have a table in which for one of the colums there is a space and becos of that all the records that have space are appearing on the top in my dropdownlist

In spite of using LTrim(RTrim(Name)
or just LTrim
my problem is not solved please help

Select ID, Name from EmployerGroups order by Name

Open in new window

0
Comment
Question by:rowmark
  • 5
  • 5
10 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24398857
did u update the records ?

UPDATE EmployerGroups
SET Name = LTrim(RTrim(Name)
0
 

Author Comment

by:rowmark
ID: 24398877
Thanks aneesh.. I did update all the records even then some are not fixed.. How can I fix this issue
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24398950
> some are not fixed
can u provide some sample data
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:rowmark
ID: 24399005
Below are the records:
if you look at the first 4 records there is a space
Thank

19C00C68-FE9D-43BA-B0F3-023A19DC74AA      
E9776B45-AE35-459E-ABEF-D101D13A3A2F      
52C95EF6-862C-4352-801E-994437ABC5FD       David Andrews
FC5AECE4-E922-483D-BC4D-9AC88364EC95       Equities
58EA0141-D34C-413C-B98E-C19E32641DB3       NewOne
B3B3E3EF-E091-491D-AA08-D64DEE0D4681       Samuel Adams
5786800F-E500-49D1-837B-9399817E7DDA      AAA MidAtlantic
F92E56D4-0998-4505-A98B-B2C3CEA17009      Abe Smith
11790D20-6009-43C0-9FA4-CAB7AA781406      ADP
8FFEFE80-7AC6-45BA-8634-835AD2092106      Alan Steinthal
90A82FC4-80F9-416A-BCC0-6F453914732D      Alex Betinski
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24399031
SELECT * FROM EmployerGroups
WHERE LEN(Name) <>  LEN(LTrim(RTrim(Name))
0
 

Author Comment

by:rowmark
ID: 24399101
The above query is returning 0 records..
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24399124
i think it must be some other charecters, it is not the space
SELECT ASCII(Name) FROM EmployerGroups  WHERE <PrimaryKEy of those 4 records >
0
 

Author Comment

by:rowmark
ID: 24399146
NULL
NULL
160
160
160
160
160
65
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24399176

UPDATE EmployerGroups
SET Name = REPLACE (NAME, char(160) ,'')
WHERE NAME LIKE char(160)+'%'
0
 

Author Closing Comment

by:rowmark
ID: 31582075
Perfect. Thanks
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
check the deletion of SQL job on who delete/disable it 12 37
email about the whoisactive result 7 36
Sql query 107 64
Rename SQL Instance/SQL Developer Edition 2012 2 19
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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