Solved

LTrim in SQL Server not working

Posted on 2009-05-15
10
817 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
Comment Utility
did u update the records ?

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

Author Comment

by:rowmark
Comment Utility
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
Comment Utility
> some are not fixed
can u provide some sample data
0
 

Author Comment

by:rowmark
Comment Utility
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
Comment Utility
SELECT * FROM EmployerGroups
WHERE LEN(Name) <>  LEN(LTrim(RTrim(Name))
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:rowmark
Comment Utility
The above query is returning 0 records..
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
Comment Utility
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
Comment Utility
NULL
NULL
160
160
160
160
160
65
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
Comment Utility

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

Author Closing Comment

by:rowmark
Comment Utility
Perfect. Thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

12 Experts available now in Live!

Get 1:1 Help Now