SSIS - 在 OLE DB 源的命令文本中使用 MERGE T-SQL
[SSIS 2008 R2]
我的控制流程如下所示:
截断 SSIS 服务器本地数据库(例如 DB_Staging)中的临时表 -->
通过数据流从外部 SQL Server(例如 DB_SOURCE)加载临时表 -->
使用 T-SQL MERGE 查询在暂存之间进行 UPDATE、INSERT 和 DELETE 表和 SSIS 服务器本地的不同数据库(例如 DB_DESTINATION)中的表
对于第三步,我有一个连接到 DB_DESTINATION 的数据流任务。此任务的数据流将 OLE DB 源设置为包含 T-SQL MERGE 语句的 SQL 命令(为简洁起见,对查询进行了剪裁):
MERGE dbo.destination AS dest
USING (SELECT * FROM DB_STAGING.dbo.source) AS src
ON ...
WHEN MATCHED
AND ...
THEN UPDATE SET
...
WHEN NOT MATCHED BY TARGET
THEN INSERT
...
WHEN NOT MATCHED BY SOURCE
AND ...
THEN DELETE;
问题是,我在 OLE DB 中的 T-SQL MERGE 查询上收到验证错误来源。我是 SSIS 新手,所以我不确定出了什么问题。加载临时表和 MERGE 的查询有效,正如我在 Management Studio 中测试的那样。有人可以提供任何指导吗?来自 BIDS 的验证错误消息是:
验证错误。 DFT_MergeData OLEDB_DB_DESTINATION [1]:无列 SQL命令返回信息。
[SSIS 2008 R2]
My Control Flow looks like this:
Truncate staging table in a DB (e.g. DB_Staging) local to the SSIS server -->
Load the staging table via a Data Flow from an external SQL Server (e.g. DB_SOURCE) -->
Use a T-SQL MERGE query to UPDATE, INSERT, and DELETE between the staging
table and an table in a different DB (e.g. DB_DESTINATION) local to the SSIS server
For the third step, I have a Data Flow Task connecting to DB_DESTINATION. The Data Flow for this task has an OLE DB source set to SQL Command containing the T-SQL MERGE statement (query snipped for brevity):
MERGE dbo.destination AS dest
USING (SELECT * FROM DB_STAGING.dbo.source) AS src
ON ...
WHEN MATCHED
AND ...
THEN UPDATE SET
...
WHEN NOT MATCHED BY TARGET
THEN INSERT
...
WHEN NOT MATCHED BY SOURCE
AND ...
THEN DELETE;
The problem is, I am getting a validation error on the T-SQL MERGE query in the OLE DB Source. I'm new to SSIS, so I am not sure what is wrong. The queries to load the staging table and to MERGE work, as I have tested them in Management Studio. Can anyone offer any guidance? The validation error message from BIDS is:
Validation error. DFT_MergeData OLEDB_DB_DESTINATION [1]: No column
information was returned by the SQL command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据流中的 OLE DB 源需要一个在列中生成输出的语句(SELECT 语句)。 MERGE 语句对此不是有效的语句。
如果要使用 MERGE 语句,则可以在控制流中的执行 SQL 语句任务中使用它,这将取代数据流任务。
The OLE DB Source in a Data Flow requires a statement that produces output in columns (a SELECT statement). The MERGE statement is not a valid statement for this.
If you want to use the MERGE statement, you would use it in a Execute SQL Statement task in the control flow, which would replace the Data Flow task.