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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Separate data from one column to many

Status
Not open for further replies.

Idokyoku2

Technical User
May 16, 2004
57
US
Hello All,
I'd like to take a table provided by a customer that has four columns provided as one like so:
Business_Addr
1123 Main st Los Angeles CA 90057

and split them out into different columns:
Addr1 City State Zip
1123 Main St Los Angeles CA 90057

Not sure exactly how to go about it.

Tried something like;
Insert into Active02-02 (BusAddr1)
Select Substring(RTRIM(Business_Addr,1,' '))
From Active02;

Only I receive an Error
The RTRIM Function requires 1 arguments.

Some advise please.
David

 
This is one of those jobs that you shouldn't bother trying to do in one step. Peal off the last 5 digits and put them in the zip field and put the remaining string in another field (temporary). Look at the results (sort on zip). Adjust and rerun if necessary because of potential data problems, eg. 9 digit zip code or no zip code, etc. You will probably have to make manual corrections too. Then try to peal off the state code...
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
I unfortunately have a number of these tables, but I'll give
it a go!
Thanks,
David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top