Showing posts with label Script Component. Show all posts
Showing posts with label Script Component. Show all posts

Saturday, January 9, 2016

Split multiple values in one field into rows in SSIS

In some cases, one filed might have multiple values with comma separated, you might need to normalized and make it as multiple records. In this situation, SSIS script component gives more flexibility to split into multiple records or normalize the records.
  public override void Input0_ProcessInputRow(Input0Buffer Row)
   {
       string s = Row.sscale;
       var primeArray = s.Split(',');
       int indice = 1;


       for (int i = 0; i < primeArray.Length; i += 1)
       {
           string value = primeArray[i];
           //value = value.Replace(",",".");
           Output0Buffer.AddRow();
           Output0Buffer.scalevalue = primeArray[i];
           Output0Buffer.idcartola = Row.idcartola;
           Output0Buffer.courseid = Row.course;
           Output0Buffer.scaleid = Row.idscale;
           Output0Buffer.scaleindex = indice;
           Output0Buffer.scalevalue = value;
           Output0Buffer.actid = Row.idact;
           Output0Buffer.moodleinst = instance;
               
               indice = indice + 1;

       }
Cheers!
Uma