Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I remove leading spaces from a table? 1

Status
Not open for further replies.

thewhistler1

Technical User
Jan 20, 2008
35
US
I recently imported a large amount of contact info into my database and now the last_name column has a space before the name and some of them have several spaces after the name?

Is it possible to remove these spaces with an update command, a function or with trim?

Thanks
 
Excellent !!!

Thank you

now if I wanted to take off multiple spaces at the end would I need to repeat the process several times like this:

update contact set last_name = ltrim (last_name) where name like '% ';

or would one time get all the spaces off the end?

Thanks again
 
Hi

thewhistler1, please read the documentation, chapter "String Functions and Operators".

From there you can find out that there are more trimming functions. And the "l" in [tt]ltrim()[/tt] stands for left. And for trimming from the right end, you have to use another function. And you can trim from both ends at once using another function. And trimming functions remove one or more of the specified characters. And many more...

stefanwagner gave you the information for starting out. Now go and read the documentation.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top