ssis ftp get multifiles

keeking發表於2011-09-13

http://www.robsymonds.com/ssis-output-to-multiple-files/

 

 

http://www.sqlservercentral.com/Forums/Topic577774-148-1.aspx

http://www.cozyroc.com/script/get-ftp-file-list-task

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76989



Foreach Loop Container
Foreach ADO Enumerator
User::a
vCol
vVal
a
Full result set
select col, val from tbale
ResultSet User::a 0
 
 ReadOnlyVariable User::vCol,User::vVal
 Input and output: col1,col2
 
 public override void CreateNewOutputRows()
    {
        /*
          Add rows by calling the AddRow method on the member variable named "Buffer".
          For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
        */
      
        Output0Buffer.AddRow();
        Output0Buffer.col = Variables.vCol;
        Output0Buffer.val = Variables.vVal;
    }




 public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
          Add your code here
        */
      
        string fileLoc = @"c:\" + Row.col;
        FileStream fs = null;
        if (!File.Exists(fileLoc))
        {
            using (fs = File.Create(fileLoc))
            {
                fs.Write(System.Text.Encoding.Default.GetBytes(Row.val), 0, Row.val.Length);
            }
        }
        else
        {
            using (StreamWriter sw = new StreamWriter(fileLoc))
            {
                sw.Write(Row.val);
            }
        }
    }

----------------------------------------------------------------------------------------------------
 
Public Sub Main()
  '
  ' Add your code here
        '
        Dim DestFileName As Variables
        Dim DestPath As Variables
        Dim strTargetFile As String
        Dim strSelectSQL As String
        Dts.VariableDispenser.LockForRead("User::DestPath")
        Dts.VariableDispenser.GetVariables(DestPath)
        Dts.VariableDispenser.LockForRead("User::DestFileName")
        Dts.VariableDispenser.GetVariables(DestFileName)
        strTargetFile = DestPath(0).Value.ToString & DestFileName(0).Value.ToString & ".txt"
        strSelectSQL = "select XmlContent,XMLFileNumber from WeijunHe.dbo.LocalXML where XMLFileName = '" & DestFileName(0).Value.ToString & "'"
        Dts.Variables("User::TargetFile").Value = strTargetFile
        Dts.Variables("User::SelectSQL").Value = strSelectSQL
        DestPath.Unlock()
        DestFileName.Unlock()
  Dts.TaskResult = ScriptResults.Success
 End Sub

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7899089/viewspace-707210/,如需轉載,請註明出處,否則將追究法律責任。

相關文章