OLE DB 命令 DT_NTEXT 输出类型和 XML 输入

OLE DB Command DT_NTEXT Output Type and XML input

我正在处理如下图所示的 SSIS 数据流。这是流程的详细信息。

  1. 获取一些记录。
  2. 添加一个 DT_NTEXT 类型的虚拟列
  3. 这是一个正在执行存储过程的 OLE DB 命令。存储过程的输出为 XML,但类型为 NVARCHAR(MAX)。输出正在填充虚拟字段。
  4. 正在将 XML 从虚拟列写入 table。

执行程序包时,目标数据库只会填充 < 而不是完整的 XML。如果我将虚拟列更改为键入 WSTR,则 XML 会成功地完整写入 table。我需要将 XML 写入 NVARCHAR(MAX) 字段,因为 XML 可能很大并超出 WSTR 类型的限制。

有谁知道发生了什么以及如何将 XML 写入 NVARCHAR(MAX) 字段?

经过 运行 多次实验和互联网搜索后,这似乎是 SSIS 中的一个问题,因为 OLE DB 命令无法映射到 DT_NTEXT 列:

作为解决方法,您可以使用脚本组件通过参数化 SQL 命令获取 XML 值,并将输出映射到输出列(无需使用派生列转换创建列)。


更新 1

搜索时,我发现这是 Microsoft 论坛中的一个未解决问题:

Microsoft 支持团队提供了以下反馈:

OLE DB clients handle XML columns (which are not part of the OLE DB spec, but SQL specific) like they would NTEXT fields. The OLE DB provider for the SQL Task currently does not fully support LOB fields ' if you store the result in an Object variable, it will return a COM object that points to the stream of data, but not the actual results (which isn't very useful).

There are a couple of workarounds for this problem.

1) Cast the results to varchar, and use a String variable
2) Use an ADO.NET connection instead of OLE DB

Considering the amount of work involved in changing/fixing the current behavior, and that there are workarounds available, we've decided not to fix this issue in this release.