Solved

LTrim in SQL Server not working

Posted on 2009-05-15
10
818 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
 

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

21 Experts available now in Live!

Get 1:1 Help Now