我在學習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