#title SSIS - 스크립트구성요소 [[TableOfContents]] ==== 누적(스크립트구성요소 - 변환) ==== {{{#!geshi vbnet ' Microsoft SQL Server Integration Services user script component ' This is your new script component in Microsoft Visual Basic .NET ' ScriptMain is the entrypoint class for script components Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper Imports Microsoft.SqlServer.Dts.Runtime.Wrapper Public Class ScriptMain Inherits UserComponent Dim CumulatedCnt As Integer Public Sub New() CumulatedCnt = 0 End Sub Public Overrides Sub 입력0_ProcessInputRow(ByVal Row As 입력0Buffer) ' ' Add your code here ' CumulatedCnt = CumulatedCnt + Row.NewAccountCnt Row.TotalAccountCnt = CumulatedCnt End Sub End Class }}} ==== 원본 ==== Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper Imports Microsoft.SqlServer.Dts.Runtime.Wrapper Public Class ScriptMain Inherits UserComponent Public Overrides Sub CreateNewOutputRows() With 출력0Buffer .AddRow() : .COL1 = 1 : .COL2 = "'AAA'" .AddRow() : .COL1 = 2 : .COL2 = "'BBB'" .AddRow() : .COL1 = 3 : .COL2 = "'CCC'" .AddRow() : .COL1 = 2 : .COL2 = "'ZZZ'" .AddRow() : .COL1 = 2 : .COL2 = "'111'" .AddRow() : .COL1 = 2 : .COL2 = "'ZZZ'" End With End Sub End Class ==== HexString To Binary ==== {{{ 'Mac Address Dim Mac(5) As Byte Dim i As Integer For i = 0 To Row.MacAddress.Length - 1 Step 2 Mac(CType(i / 2, Int32)) = Convert.ToByte(Row.MacAddress.Substring(i, 2), 16) Next Row.MacAddrBin = Mac }}} {{{ /// /// Convert string to byte_array /// /// private byte[] String_To_Bytes(string strInput) { // i variable used to hold position in string int i = 0; // x variable used to hold byte array element position int x = 0; // allocate byte array based on half of string length byte[] bytes = new byte[(strInput.Length) / 2]; // loop through the string - 2 bytes at a time converting // it to decimal equivalent and store in byte array while (strInput.Length > i + 1) { long lngDecimal = Convert.ToInt32(strInput.Substring(i, 2), 16); bytes[x] = Convert.ToByte(lngDecimal); i = i + 2; ++x; } // return the finished byte array of decimal values return bytes; } /// /// Convert byte_array to string /// /// private string Bytes_To_String(byte[] bytes_Input) { // convert the byte array back to a true string string strTemp = ""; for (int x = 0; x <= bytes_Input.GetUpperBound(0); x++) { int number = int.Parse(bytes_Input[x].ToString()); strTemp += number.ToString("X").PadLeft(2, '0'); } // return the finished string of hex values return strTemp; } }}}