0

I got some formatting issue in ssis. I have some sets of telephone numbers from text files and a hyphen needs to be added with this format.

ex. 1234567890 formatted: 123-456-7890

Im thinking using substring in expression from derived column task. Hope u can help. Thanks!

dion_123
  • 1
  • 1
  • 1
    someting along the lines of `SUBSTRING(field,1,3) + "-" + SUBSTRING(field,4,3) + "-"+ SUBSTRING(field,7,4)` – MiguelH Sep 21 '15 at 09:17
  • 1
    possible duplicate of [SSIS How to get part of a string by separator](http://stackoverflow.com/questions/10921645/ssis-how-to-get-part-of-a-string-by-separator) –  Sep 21 '15 at 09:23

1 Answers1

0
public static String setHyphen(String str) {
        StringBuilder stringBuilder = new StringBuilder();
        char ssnArr[] = str.toCharArray();
        for(int i=0;i<ssnArr.length;i++){
            if(i == 2  || i == 5){
                stringBuilder.append(ssnArr[i] + "-");
            }else{
                stringBuilder.append(ssnArr[i]);
            }
        }
        return stringBuilder.toString();
    }
ngg
  • 1,493
  • 19
  • 14