2013-03-12 1652 views
0

我需要從一組csv文件中讀取行並將其寫入數據庫中的現有表中。然而,爲了做到這一點,我需要將平面文件數據與我數據庫中的表中的兩個選定值相結合。我在SSIS中構建了一個應該允許使用Lookup轉換的設計。但是,它不工作:(將OLE DB查找與平面文件結合起來SSIS

這裏是我的設計:

enter image description here

當我調試我得到的消息:

Error at Contacts [SSIS.Pipeline]: input column "ObjectId" (914) has lineage ID 709 that was not previously used in the Data Flow task. 
Error at Contacts [SSIS.Pipeline]: "component "OLE DB Destination" (134)" failed validation and returned validation status "VS_NEEDSNEWMETADATA". 
Error at Contacts [SSIS.Pipeline]: One or more component failed validation. 
Error at Contacts: There were errors during task validation. 
(Microsoft.DataTransformationServices.VsIntegration) 

的ObjectId是我在查找裏面選擇一個int 。查詢的整個查詢是:

DECLARE @ObjectId int 
Select @ObjectId = (SELECT TOP (1) [Value] as ObjectId 
FROM dbo.Sequences WHERE (Name = 'Contact')); 
UPDATE Sequences SET Value = Value + 1 WHERE (Name = 'Contact'); 
SELECT ObjectId = @ObjectId, Reference = N'CU' + cast(@ObjectId as VARCHAR(20)) 

此查詢在預覽中完美工作。有人可以告訴我我做錯了什麼嗎?對我的無知抱歉,但這是我在SSIS中做的第一件事。

更新1(見@billinkc答案)

新設計:

enter image description here

新的錯誤:(

Error at Contacts [Lookup Sequence [531]]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. 
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Syntax error, permission violation, or other nonspecific error". 
Error at Contacts [Lookup Sequence [531]]: OLE DB error occurred while loading column metadata. Check SQLCommand and SqlCommandParam properties. 
Error at Contacts [SSIS.Pipeline]: "component "Lookup Sequence" (531)" failed validation and returned validation status "VS_ISBROKEN". 
Error at Contacts [SSIS.Pipeline]: One or more component failed validation. 
Error at Contacts: There were errors during task validation. 
(Microsoft.DataTransformationServices.VsIntegration) 

回答

1

您查找應生成EntityGUID後直列而不是一個聯合,但是,看着你的查找代碼,這不是Lookup的工作方式。查找是隻讀類型的操作

相反,您需要將其更改爲OLE DB Command對象。

最後,您必須生成這些ID的SQL代碼。那是......如果你有興趣,那可以更有效地完成。

+0

我已經改變了它。它現在是內聯的,但我仍然遇到錯誤。很快會更新我的問題。是的,我感興趣。請告訴我。 – Kev 2013-03-12 17:06:34

0

我有一個類似的錯誤0x80004005驅使我堅果。我的調試指向OLEDB源,但實際上是因爲我在測試期間更改了連接以將RetainSameConnection設置爲true,並且它需要設置爲false。因此請檢查您的所有連接,以及您可能已更改的任何其他內容。

相關問題