Why is this SSIS package throwing conversion errors?
When I run it I get the following error:
Error at Data Flow Task [SQL Server Destination [164]]: The column "S开发者_高级运维epticSystemType" can't be inserted because the conversion between types DT_NTEXT and DT_WSTR is not supported.
But according to this diagram that cast is legal:
http://msdn.microsoft.com/en-us/library/ms141704.aspx
Am I missing something?
Here is a possible option. You could use Data Conversion Transformation
task available in Data Flow Task to convert input from one data type to another. Following example shows how this can be done.
Step-by-step process:
- Create two tables named
dbo.DataNText
anddbo.DataUnicode
as shown in screenshots #1 and #2. - Create a package with one data flow task. Configure data flow task with a OLE DB soruce, Data Conversion task and OLE DB destination. Refer screenshot #6 to see how the tasks are configured.
NText
is a OLE DB source task;Conversion
is a Data Conversion Transformation task; andUnicode
is a OLE DB destination task. - NText is configured to retrieve data from table
dbo.DataNText
. Column mapping is done as shown in screenshot #3. - Conversion task is configured as shown in screenshot #4. Select the column to convert, provide a name to the output column. Usually it is named as
Copy of
. Change the data type toUnicode String [DT_WSTR]
and provide a length255
. These values are for this example to show how the conversion configuration is done. - Unicode is configured to save data to the table
dbo.DataUnicode
. Column mapping is done as shown in screenshot #5. - Sample package execution is shown in screenshot #6.
- Sample data contents of both the tables are shown in screenshot #7.
This can also be achieved using Derived Column Transformation
task.
Hope that helps.
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
Screenshot #5:
Screenshot #6:
Screenshot #7:
Just under that diagram, it also says that casting to DT_WSTR requires parameters. Are you following that?
(DT_WSTR,20) casts 20 byte pairs, or 20 Unicode characters, to the DT_WSTR data type.
edit: Please see Siva's answer for steps to achieve this with another task.
精彩评论