Free Jobs
Reference




Java Forums: Core Java (15) J2EE (3) EJB (5) Servlet (3) JDBC (6) Hibernate (2) Struts (1) Swing (1) Oracle (7) JSP (4) Other (10)

Topic: How to use ltrim and rtrim to remove blank spaces in DataColumns in Oracle

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share





User: mohit555 Post Date: 14 Jan 2011 09:14

Introduction:
In this post I will give the query to remove blank spaces in DataColumns in Oracle using ltrim and rtrim keyword.



Main Content:
So many times data with blank spaces may have entered in a datacolumn
of Oracle or SQLServer Database :

In this post I will be removing Blank spaces from start and end of the each data in a column.
Effetively trimming from front and back but not doing anything for spaces in the middle of string.

SELECT LTRIM(SampleColumn) AS "LTRIM"
FROM Freshers

SELECT RTRIM(SampleColumn) AS "RTRIM"
FROM Freshers

SELECT LTRIM(RTRIM(SampleColumn)) AS "LRTRIM"
FROM Freshers

Also you can remove the leading and trailing spaces from the column data by

update MyTable set SampleColumn = ltrim(rtrim(SampleColumn))



Conclusion:
This query will left trim and right trim all the data in SampleColumn of
Table MyTable



About Writer:
Hi All,I am Java Developer From Bangalore


Writer's Link:

Writer's Email:







Comments:
Post Comment





Similar Articles Top ArticlesLatest Articles Other Articles by this Author







www.freejobsreference.com Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)