| Author |
Topic |
|
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2007-08-24 : 08:59:55
|
| I have source file which is in the following format id source1 Person,Defendant,1961,a,M,John, Smith, Jr,F,Katie, Jones2 Person,Attorney,n,M,John, Doe,M,Mark, Levey,3 Person,Attorney,,y,F,samantha, Fox,M,Mathew, connell, IV,I want the data between identfiers 'Person,' and ',M,', ',F,'.for the above example output should be id SOURCE1 SOURCE2 SOURCE3______________________________________________________________________1 Defendant,1961,a John, Smith, Jr Katie, Jones2 Attorney,n John, Doe Mark, Levey,3 Attorney,,y samantha, Fox Mathew, connell, IV,Since the data is not fixed length between identifiers substring and charindex doesnt seem to work.Any suggestions and inputs would helpThanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-24 : 09:09:34
|
| You need to import the file to the staging table and then queryselect replace(replace(replace(replace(source,' person,',' '),' and ',' '),',M,',' '),',F,',' ') as valid_source from staging_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2007-08-24 : 09:44:04
|
| Thanks madhivinan I changed the query little bit to add new delimiter instead of ',D,' and ',I,' so that I can parse it outreplace(replace(replace(replace(col004,' D,',' '),' and ',' '),',I,','||'),',D,','||') as valid_souce Thanks |
 |
|
|
|
|
|