将OLE DB查找与平面文件结合起来SSIS

问题描述:

我需要从一组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) 

您查找应生成EntityGUID后直列而不是一个联合,但是,看着你的查找代码,这不是Lookup的工作方式。查找是只读类型的操作

相反,您需要将其更改为OLE DB Command对象。

最后,您必须生成这些ID的SQL代码。那是......如果你有兴趣,那可以更有效地完成。

+0

我已经改变了它。它现在是内联的,但我仍然遇到错误。很快会更新我的问题。是的,我感兴趣。请告诉我。 – Kev 2013-03-12 17:06:34

我有一个类似的错误0x80004005驱使我坚果。我的调试指向OLEDB源,但实际上是因为我在测试期间更改了连接以将RetainSameConnection设置为true,并且它需要设置为false。因此请检查您的所有连接,以及您可能已更改的任何其他内容。