cdfllc
asked on
Ridiculous String parsing
I know this is probably impossible, but does anybody have an idea how to convert a column with contents like:
6465 Waygata Blvd #404
St. Louis Park, MN 55426
Into This:
Address1 City State Zip
---------- ---- ------ ----
6465 Waygata Blvd #404 St. Louis Park MN 55426
thanks for any suggestions,
cdfllc
6465 Waygata Blvd #404
St. Louis Park, MN 55426
Into This:
Address1 City State Zip
---------- ---- ------ ----
6465 Waygata Blvd #404 St. Louis Park MN 55426
thanks for any suggestions,
cdfllc
declare @addr varchar(250)
set @addr='6465 Waygata Blvd #404
St. Louis Park, MN 55426
'
select substring(@addr,1,charinde x(char(13) ,@addr,1)- 1) adress,
substring(@addr,charindex( char(13),@ addr,1)+1, charindex( ',',@addr, 1)-1) adress2,
rtrim(substring(@addr,char index(',', @addr,1)+2 ,2)) state ,
ltrim(right(@addr,(len(@ad dr)-(chari ndex(',',@ addr,1)+3) ))) zip
set @addr='6465 Waygata Blvd #404
St. Louis Park, MN 55426
'
select substring(@addr,1,charinde
substring(@addr,charindex(
rtrim(substring(@addr,char
ltrim(right(@addr,(len(@ad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you sure you want to do this? What about different adress formats, commas in the city name, po-box numbers, etc? If you just need to convert an existing batch of adresses, this might be a good start -- but I wouldn't do it and hope for a perfect translation (it's not possible in a simple query..)
Just my 2eurocents :)
John
Just my 2eurocents :)
John
ASKER
you are right softplus, I am just converting an existing batch of addresses...
Not hoping for a perfect result...
thanks everyone!
cdfllc
Not hoping for a perfect result...
thanks everyone!
cdfllc
6465 Waygata Blvd #404
St. Louis Park, MN 55426
in one Column ?