ssis ftp get multifiles

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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7899089/viewspace-707210/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值