Solved

Remove space from end of all records in a table

Posted on 2014-10-09
1
90 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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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