我在学习SSIS,这看起来像一个简单的任务,但我卡住了。SSIS使用来自.CSV文件的参数执行存储过程SQL Server 2005
我有一个CSV文件Orders.csv与此数据:
ProductId,Quantity,CustomerId
1,1,104
2,1,105
3,2,106
我也有一个存储过程ssis_createorder其作为输入参数: @ProductID INT @Quantity INT @CustomerID INT
我想要做的是创建一个SSIS包,它将.csv文件作为输入并对.csv文件中的每一行调用ssis_createorder三次(第一行包含列名)。
这是我到目前为止所做的。
我已经创建了一个SSIS包(Visual Studio 2005 & SQL Server 2005)。
在控制流中我有一个数据流任务。
数据流具有我的.csv文件的平面文件源。所有的列都被映射。
我已经创建了一个名为order类型为Object的变量。我也有变量CustomerId,ProductId,& int32类型的数量。
Next我有一个Recordset Destination将.csv文件的内容分配给varialbe命令。我不确定如何使用此工具。我将VariableName(在Customer Properties下)设置为User :: orders。我认为,现在订单保存了由原始.csv文件中的内容组成的ADO记录集。
接下来,我在控制流标签上添加一个ForEach循环容器,并将其链接到数据流任务。
ForEach循环容器内部我将Enumerator设置为“ForEach ADO Enumerator”。我将“ADO对象源变量”设置为User :: orders“对于枚举模式,我选择”第一个表中的行“
在变量映射选项卡中,我有User :: ProductId索引0,用户::数量指标1,用户::客户ID指数2.我不知道这是否是正确的。
接下来,我有一个脚本任务foreach循环容器内。
我必须设置为ReadOnlyVariables产品号
在主要方法这是我在做什么:
Dim sProductId As String = Dts.Variables("ProductId").Value.ToString
MsgBox("sProductId")
当我运行包我的foreach循环容器将鲜艳的红色和我得到了以下错误消息
Error: 0xC001F009 at MasterTest: The type of the value being assigned to variable "User::ProductId" 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::ProductId" cannot be applied.
Error: 0xC001F009 at MasterTest: The type of the value being assigned to variable "User::Quantity" 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 2 to variable "User::Quantity" cannot be applied.
Error: 0xC001F009 at MasterTest: The type of the value being assigned to variable "User::CustomerId" 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 3 to variable "User::CustomerId" cannot be applied.
Warning: 0x80019002 at MasterTest: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (12) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.
Dts.TaskResult = Dts.Results.Success
任何帮助,将不胜感激
这似乎是处理数据的最有效方式。确保你的数据类型匹配。 – bobs 2010-09-22 19:13:37