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:
Address
"20 Test Street, Testville"
"22 Test Avenue"
"Flat 2, 41 Test Close, Testville"
I would like the data to look like:
Add1,Add2,Add3,Add4,Add5
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.
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:
Address
"20 Test Street, Testville"
"22 Test Avenue"
"Flat 2, 41 Test Close, Testville"
I would like the data to look like:
Add1,Add2,Add3,Add4,Add5
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.