[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

LTrim in SQL Server not working

Posted on 2009-05-15
10
Medium Priority
?
836 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
[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
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 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