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

Address Formatting

Status
Not open for further replies.

NiceArms

Programmer
May 21, 2009
105
GB
Hi ppl,

This is a little backwards as I know how to do this but I could really do with an easier way.

I have the situation where I have addresses (postal) that I need to extract from SQL. Unfortunately the address do differ from field to field e.g.

address1, blank, address3, address4, postcode
blank, blank, address3, address4, postcode
address1, blank, blank, address4, postcode

I need the extract to shift the fields that contain data to the left, into the blank fields.

So take the above and make it:

address1, address3, address4, blank, postcode
address3, address4, blank, blank, postcode
address1, address4, blank, blank, postcode

I could do this using a CASE statement, however this will get very long and unpleasantly complicated very quickly.

Does anyone know of another way?
 
Do you want to return the data in separate columns, or do you want it returned in one column separated by commas?


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Hi George,

to be honest I don't think it would be a bad thing to know both methods (;p), however should you not have the time I would prefer: into serparate columns.

/Nice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top