_대문 | 방명록 | 최근글 | 홈피소개 | 주인놈
FrontPage › SSIS-Split

다음과 같이 ssis 패키지를 꾸며놓고...

01.png

OLE DB 원본 #

select 1 p_key, '1,100|2,200|3,300' money_log
union all
select 1 p_key, '6,600|5,500|4,400' money_log
union all
select 1 p_key, '7,700|8,800|9,900|10,1000' money_log

스크립트 구성요소 #

스크립트 구성요소에서 "out2"라는 출력을 추가하고...
/* Microsoft SQL Server Integration Services Script Component
*  Write scripts using Microsoft Visual C# 2008.
*  ScriptMain is the entry point class of the script.*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{

    public override void PreExecute()
    {
        base.PreExecute();
        /*
          Add your code here for preprocessing or remove if not needed
        */
    }

    public override void PostExecute()
    {
        base.PostExecute();
        /*
          Add your code here for postprocessing or remove if not needed
          You can set read/write variables here, for example:
          Variables.MyIntVar = 100
        */
    }

    public override void 입력0_ProcessInputRow(입력0Buffer Row)
    {
        /*
          Add your code here
        */
        string[] result = Row.moneylog.Split(new char[] { '|', ',' });

        for (int i = 0; i < result.Length; i++)
        {
            out2Buffer.AddRow();
            out2Buffer.pkey = Row.pkey;
            out2Buffer.moneycode = int.Parse(result[i].ToString());
            out2Buffer.gamemoney = int.Parse(result[i + 1].ToString());
            i++;
        }
    }

    public override void CreateNewOutputRows()
    {
        /*
          Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
          For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
        */
    }

}

out2 결과 #

02.png


C#에서 변수처리는 이렇게..
Dts.Variables["변수"].Value = "변수값이냐?"; 
-- 이재학 2011-12-22 10:01:44

댓글 남기기..
이름: : 오른쪽의 새로고침을 클릭해 주세요. 새로고침
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

사람은 누구에게나 마음의 정원이 있다. (이철환)