SSIS - OLE DB Command DT_NTEXT Output Type and XML input
Problem:
Solution:
Original post: https://stackoverflow.com/questions/58133568/ole-db-command-dt-ntext-output-type-and-xml-input/58158225#58158225
I am working on an SSIS data flow as shown in the image below. Here are the details of the flow.
- Getting some records.
- Adding a dummy column which is a DT_NTEXT type
- This an OLE DB command which is executing a stored procedure. The output of the stored procedure is XML but is of type NVARCHAR(MAX). The output is populating the dummy field.
- Writing the XML from the dummy column to a table.
When the package is executed, the destination DB only gets populated with a < instead of the full XML. If I change the dummy column to type WSTR, the XML is succesfully written to the table in full. I need to write the XML to an NVARCHAR(MAX) field, as the XML could be large and exceed the limits of the WSTR type.
Does anyone have an idea what is going on and how I can write my XML to an NVARCHAR(MAX) field?
Solution:
After running many experiments and searching over the internet, it looks like this is an issue in SSIS, since OLE DB Command cannot be mapped to
DT_NTEXT
columns:
As a workaround, you can use a Script Component to get the XML value using a parameterized SQLCommand, and map the output to an output column (no need to create column using a derived column transfomation).
While searching, I found that this was an open issue in the Microsoft forums:
The following feedback was given by Microsoft support team:
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 DBConsidering 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.
Original post: https://stackoverflow.com/questions/58133568/ole-db-command-dt-ntext-output-type-and-xml-input/58158225#58158225
Comments
Post a Comment