将OLE DB查找与平面文件SSIS结合使用

时间:2013-03-12 15:52:57

标签: sql-server sql-server-2008 visual-studio-2008 ssis oledb

我需要从一组csv文件中读取行并将它们写入我数据库中的现有表。但是,为了做到这一点,我需要将平面文件数据与我数据库中的表中的2个选定值组合在一起。我在SSIS中构建了一个设计,应该允许使用Lookup转换。但是,它不起作用:(

这是我的设计:

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是我在Lookup中选择的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)

2 个答案:

答案 0 :(得分:2)

在Generate EntityGUID步骤之后,您的查找应该是内联的,而不是联合。但是,查看Lookup代码,这不是Lookup的工作方式。查找是只读操作类型

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

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

答案 1 :(得分:0)

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