1

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

这是我的设计:

在此处输入图像描述

当我调试时,我收到消息:

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 答案)

新设计:

在此处输入图像描述

新错误:(

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)
4

2 回答 2

2

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

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

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

于 2013-03-12T16:52:04.860 回答
0

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

于 2013-03-18T18:20:13.927 回答