SQL Server2014的SSDT / SSIS中动态OLE DB目标的连接字符串

时间:2016-03-13 12:47:54

标签: sql sql-server ssis sql-server-data-tools

我是SQL Server的新手,但不是SQL或编程。我一直在阅读可用的在线文档和教程,以便在SSDT / SSIS中设置一个For循环,循环遍历文件夹中的一系列平面文件,并为每个具有相同名称的文件创建一个DB对象。

循环有效,但为OLE DB目标管理器设置连接字符串除外。我的服务器名为' OLEGS_LAPTOP'使用名为“足球数据”的数据库我正在使用以下连接字符串:

"Provider=SQLNCLI11.0;Server=OLEGS_LAPTOP;Source=(local);Initial Catalog="+ @[User::FileFound] + "Football Data"+";Integrated Security=SSPI;Auto Translate=False;"

此处,@[User::FileFound]表示在平面文件连接管理器中设置的变量,用于循环浏览我选择的本地文件夹中的文件。当我尝试将此连接字符串用于OLE DB对象时,出现以下错误:

TITLE: Package Validation Error
------------------------------

Package Validation Error

------------------------------
ADDITIONAL INFORMATION:

Error at Data Flow Task [OLE DB Destination [10]]: 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 11.0"  Hresult: 0x80004005  Description: "Unspecified error".
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "The metadata could not be determined because every code path results in an error; see previous errors for some of these.".
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Invalid object name 'dbo.OLE DB Destination'.".

Error at Data Flow Task [OLE DB Destination [10]]: Failed to open a fastload rowset for "[dbo].[OLE DB Destination]". Check that the object exists in the database.

Error at Data Flow Task [SSIS.Pipeline]: "OLE DB Destination" failed validation and returned validation status "VS_ISBROKEN".

Error at Data Flow Task [SSIS.Pipeline]: One or more component failed validation.

Error at Data Flow Task: There were errors during task validation.

 (Microsoft.DataTransformationServices.VsIntegration)

------------------------------
BUTTONS:

OK
------------------------------

任何人都可以告诉我在字符串中需要更改的内容才能获得所需的结果吗?

由于

继续到目前为止给出的答案/支持:

我现在收到的错误消息是:

TITLE: Package Validation Error
------------------------------

Package Validation Error

------------------------------
ADDITIONAL INFORMATION:

Error at Data Flow Task [OLE DB Destination [10]]: A destination table name has not been provided.

Error at Data Flow Task [SSIS.Pipeline]: "OLE DB Destination" failed validation and returned validation status "VS_ISBROKEN".

Error at Data Flow Task [SSIS.Pipeline]: One or more component failed validation.

Error at Data Flow Task: There were errors during task validation.

 (Microsoft.DataTransformationServices.VsIntegration)

------------------------------
BUTTONS:

OK
------------------------------

1 个答案:

答案 0 :(得分:0)

看起来好像是字符串" OLE DB Destination"进入table\view映射(第一个屏幕截图),[dbo].[OLE DB Destination]作为表名出现。也许您已在OpenRowset属性窗口的OLE DB Destination属性中用此字符串替换了表名(第二个屏幕截图)。

enter image description here

enter image description here

稍后编辑

为了能够从变量获取表名(假设您有这样的变量并为其分配了表名),您需要将OLE DB Destination的{​​{1}}属性更改为AccessMode并在OpenRowset From Variable属性中指定变量名称(参见下图)

enter image description here