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