SSIS Foreach 循环文件夹作为变量
我需要将 Foreach 循环中的文件夹设置为可变位置。我尝试将位置添加到我的包配置中,它的表现就像它工作一样,但是当我打开配置文件时,它不在那里。
我将其设置为 Foreach File Enumerator,并对路径进行硬编码,并检索完全限定的文件名。我的变量 Mappings 有一个索引为 0 的变量 CurrentFile。
因此,我将其更改为 Foreach From Variable Enumerator,SourceFiles 变量为 \server\path*.*。但现在它抱怨 CurrentFile,分配的值的类型与变量类型(字符串)不同。
我猜我需要以某种方式将表达式与“集合”选项卡上的枚举器一起使用?如何?
- 一般:Foreach 循环容器
- 集合:Foreach From Varialbe 枚举器;变量是 User::SourcePath;表达式(未使用)
- 变量映射:变量 User::CurrentFile,索引 0
- 表达式:(未使用)
错误:MyPackage 处的 0xC001F009:分配给变量“User::CurrentFile”的值类型与当前变量类型不同。变量在执行期间不能改变类型。变量类型是严格的,但 Object 类型的变量除外。 错误:Foreach 循环容器处的 0xC001C012:无法应用 ForEach 变量将编号 1 映射到变量“User::CurrentFile”。
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.
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.
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?
- General: Foreach Loop Container
- Collection: Foreach From Varialbe Enumerator; Variable is User::SourcePath; Expressions (not used)
- Variable Mappings: Variable User::CurrentFile, Index 0
- Expressions: (not used)
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一位同事向我展示了如何让它发挥作用。不要将其更改为“Foreach from Variable Enumerator”,而是将其保留为“Foreach File Enumerator”。
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".