SSIS Foreach循环文件夹为变量 [英] SSIS Foreach Loop Folder as variable

查看:164
本文介绍了SSIS Foreach循环文件夹为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Foreach循环中的Folder设置为可变位置.我尝试只是将位置添加到我的软件包配置中,并且它的工作方式像它正常工作,但是当我打开配置文件时,它不存在.

I need to set the Folder in my Foreach loop to a variable location. I tried just adding the location to my package configuration, and it acted like it worked, but when I opened the configuration file, it wasn't there.

我将其设置为Foreach File Enumerator,并使用硬编码的路径,并检索完全限定的文件名.我的变量Mappings的变量CurrentFile的索引为0.

I had it set to Foreach File Enumerator, with the path hardcoded, and Retrieve fully qualified file name. My variable Mappings have a variable CurrentFile with index 0.

因此,我将其更改为Foreach From Variable Enumerator,其SourceFiles变量为\ server \ path *.*.但是现在,它抱怨该CurrentFile,所分配的值的类型与变量类型(字符串)不同.

So, I've changed it to a Foreach From Variable Enumerator, with a SourceFiles variable of \server\path*.*. But now it's complaining about that CurrentFile, that the type of value being assigned differs from the variable type (string).

我猜想我需要以某种方式将表达式"与集合"选项卡上的枚举器一起使用吗?怎么样?

I'm guessing that I need to somehow use the Expressions with the Enumerator on the Collections tab? How?

  • 常规:Foreach循环容器
  • 集合:来自Varialbe枚举器的Foreach;变量是User :: SourcePath;表达式(未使用)
  • 变量映射:变量User :: CurrentFile,索引0
  • 表达式:(未使用)

错误:MyPackage处为0xC001F009:分配给变量"User :: CurrentFile"的值的类型与当前变量类型不同.变量在执行期间可能不会更改类型.变量类型是严格的,除了对象类型的变量. 错误:在Foreach循环容器处出现0xC001C012:ForEach变量将数字1映射到变量"User :: CurrentFile"不能应用.

Error: 0xC001F009 at MyPackage: The type of the value being assigned to variable "User::CurrentFile" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. Error: 0xC001C012 at Foreach Loop Container: ForEach Variable Mapping number 1 to variable "User::CurrentFile" cannot be applied.

推荐答案

一位同事向我展示了如何使其工作.不要将其更改为从变量枚举器进行Foreach",而应将其保留为"Foreach文件枚举器".

A co-worker showed me how to get it to work. Do NOT change it to "Foreach from Variable Enumerator", but leave it as "Foreach File Enumerator".

  • 集合:Foreach文件枚举器;放在Enumerator配置中的文件夹和文件中.在表达式下,将目录设置为指向目录的用户变量(它将优先于您输入的文件夹);将FileSpec设置为指向文件的用户变量(它将优先于您输入的文件).
Directory @[User::SourcePath]  (value: \\server\directory)
FileSpec @[User::CopyFileName] (value: *.*)

  • 变量映射:变量User ::当前文件,索引0
  • 表达式:(未使用)
  • 这篇关于SSIS Foreach循环文件夹为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆