Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Flat file source - split delimited address field to additional fields.

Flat file source - split delimited address field to additional fields.

Flat file source - split delimited address field to additional fields.

A client of ours can only export data in the following .csv delimited format:

ID, Name, Company, Address, Town, County, Postcode, Country

The Address field contains anything from 1 to 5 lines of local address data separated by Carriage Return.

We need to get this data into our SQL database using SSIS on a daily basis.

I have managed to import the file as Flat File, and have successfully changed the Carriage Returns in the Address field to commas.

I now have data in the Address field that represents:

"20 Test Street, Testville"
"22 Test Avenue"
"Flat 2, 41 Test Close, Testville"

I would like the data to look like:

20 Test Street,Testville,,,
22 Test Avenue,,,,
Flat 2, 41 Test Close, Testville,,
Flat 5, Test House, Test close, Test Road, Testville

I have tried using Derived Columns and the FindString and SubString commands, but I can't seem to get it to work because of the differing number of commas in each record. Sometimes there are none (second row in above examples) and sometimes more (other rows in above example).

To get the first value in the field I tried:
SUBSTRING(AddressCommas,1,(FINDSTRING(AddressCommas,",",1) - 1))

but as stated it doesn't work with the differing number of commas.

Are there any other ways I can go about this?

Note: the client has no control over the quality of their data.

RE: Flat file source - split delimited address field to additional fields.

with SSIS the easier would be to do a C# script and do the string manipulation on it, and output 1 or more columns based on your own decision - doing it with plain derived columns will be harder and performance will be slower

Or do it on a staging table on SQL - again its easy enough to create a table function to do the split


Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close