Solved

Remove space from end of all records in a table

Posted on 2014-10-09
1
92 Views
Last Modified: 2014-10-09
I have a table that contains a lot of usernames. Some of the usernames is stored with a trailing space, and I need to remove this. It means that "johndoe[space]" should be "johndoe".

This SQL returns all records that has usernames ending with space:

SELECT TOP (1000) UserName FROM tblUserVisit WHERE (UserName LIKE '% ')

Open in new window


How can this SQL be modified to remove the trailing space from the usernames?
0
Comment
Question by:webressurs
[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
1 Comment
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 40370141
this will remove spaces in the end... If you want to remove spaces on the begining then you can use TRIM..

update 
tblUserVisit 
set UserName =rtrim(UserName )
where (UserName LIKE '% ')

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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