Solved

How do I remove leading space in last name field in Oracle table?

Posted on 2007-11-29
2
2,392 Views
Last Modified: 2013-12-18
I am using Oracle 10 and would like to write an update query to remove a leading space that was put in the last name field by mistake.  I have figured out how to find out what records have the leading space, but I'm stuck on the sql to actually update the data.

Thanks for your help.
Sarah

0
Comment
Question by:spendergrass
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 20377658
please try this syntax:
UPDATE yourtable 
  SET yourfield = TRIM(leading ' ' from yourfield)
WHERE yourfield like ' %'

Open in new window

0
 

Author Closing Comment

by:spendergrass
ID: 31411806
That worked perfectly.  Thank you.
0

Featured Post

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
capture vmstat info and insert it into an oracle table 31 55
Oracle DB Slows After Datapump Until Next Reboot 27 122
pl/sql parameter is null sometimes 2 23
oracle query 3 25
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

679 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