Ask a question
Quick access
- Forums home
- Browse forums users
- FAQ
Search related threads
- Remove From My Forums
Answered by:
Archived Forums 361-380
>
SQL Server Integration Services
Question
-
Sign in to vote
i got the following error when i run the ssis.
Column "XXX" cannot convert between unicode and non-unicode string data types.
but sometimes i can run successfully.
does the data casues this error or table column's data type problem?
why i can run successfully sometimes run failure?
Thursday, May 8, 2014 7:55 AM
Answers
-
Sign in to vote
Hi,
As Arthur said, the error occurs when there are Unicode characters in the NVARCHAR column of the source table. Because you use SQL command to retrieve data for the OLE DB Source, and the SQL command includes CONVERT(VARCHAR(10),x_col), the Convert operation will fail as long as there are Unicode characters in the x_col column in the source table. When the x_col column has no Unicode characters, the SQL command runs successfully, so does the package.
How to resolve the issue depends on whether the data type of thecorresponding column in thedestination table is NVARCHAR or VARCHAR.
If the destination column is of NVARCHAR data type, you can simply remove the CONVERT function from the SQL command. Since the source column is of NVARCHAR data type, the output column of the OLE DB Source is of DT_WSTR data type by default, and the column can be loaded to the destination table directly.
If the destination column is of VARCHAR data type and you don't want to insert the Unicode rows of the source table, you need to do as follows:
- Remove the CONVERT function from the query
- Use a Data Conversion Transformation to convert the target column from DT_WSTR to DT_STR.
- Open the Advanced Editor for the Data Conversion, switch to the "Input and Output Properties" tab, and expand the Output Columns node.
- Set the "TruncationRowDisposition" property of the output column from "RD_FailComponent" to "RD_RedirectRow".
Regards,
Mike Yin
TechNet Community Support- Edited by Mike Yin Tuesday, May 13, 2014 7:16 AM modify content
- Marked as answer by Mike Yin Sunday, May 18, 2014 4:53 PM
Tuesday, May 13, 2014 2:53 AM
All replies
-
Sign in to vote
it is data, datatype used, when you have unicode in the source you may not fit it into a non-unicode, but the opposite works. Need to use the Data Conversion Transformation and set that textual column to say DT_WSTR
Arthur My Blog
Thursday, May 8, 2014 7:13 PM
-
Sign in to vote
it is data, datatype used, when you have unicode in the source you may not fit it into a non-unicode, but the opposite works. Need to use the Data Conversion Transformation and set that textual column to say DT_WSTR
Arthur My Blog
column's datatype is nvarchar, i have converted it in the view using convert(varcahar(10),x_col) , why run fail? or i must convert data type in ssis ?column's datatype is nvarchar, i have converted it in the view using convert(varcahar(10),x_col) , why run fail? or i must convert data type in ssis ?column's datatype is nvarchar, i have converted it in the view using convert(varcahar(10),x_col) , why run fail? or i must convert data type in ssis ?column's datatype is nvarchar, i have converted it in the view using convert(varcahar(10),x_col) , why run fail? or i must convert data type in ssis ?
Monday, May 12, 2014 9:37 AM
-
Sign in to vote
Hi,
As Arthur said, the error occurs when there are Unicode characters in the NVARCHAR column of the source table. Because you use SQL command to retrieve data for the OLE DB Source, and the SQL command includes CONVERT(VARCHAR(10),x_col), the Convert operation will fail as long as there are Unicode characters in the x_col column in the source table. When the x_col column has no Unicode characters, the SQL command runs successfully, so does the package.
How to resolve the issue depends on whether the data type of thecorresponding column in thedestination table is NVARCHAR or VARCHAR.
If the destination column is of NVARCHAR data type, you can simply remove the CONVERT function from the SQL command. Since the source column is of NVARCHAR data type, the output column of the OLE DB Source is of DT_WSTR data type by default, and the column can be loaded to the destination table directly.
If the destination column is of VARCHAR data type and you don't want to insert the Unicode rows of the source table, you need to do as follows:
- Remove the CONVERT function from the query
- Use a Data Conversion Transformation to convert the target column from DT_WSTR to DT_STR.
- Open the Advanced Editor for the Data Conversion, switch to the "Input and Output Properties" tab, and expand the Output Columns node.
- Set the "TruncationRowDisposition" property of the output column from "RD_FailComponent" to "RD_RedirectRow".
Regards,
Mike Yin
TechNet Community Support- Edited by Mike Yin Tuesday, May 13, 2014 7:16 AM modify content
- Marked as answer by Mike Yin Sunday, May 18, 2014 4:53 PM
Tuesday, May 13, 2014 2:53 AM
-
Sign in to vote
Hi,
As Arthur said, the error occurs when there are Unicode characters in the NVARCHAR column of the source table. Because you use SQL command to retrieve data for the OLE DB Source, and the SQL command includes CONVERT(VARCHAR(10),x_col), the Convert operation will fail as long as there are Unicode characters in the x_col column in the source table. When the x_col column has no Unicode characters, the SQL command runs successfully, so does the package.
To avoid the potential issue, you need to remove the CONVERT function from the SQL command, but use a Data Conversion Transformation to do the data conversion. Since the source column is of NVARCHAR data type, the output column of the OLE DB Source is of DT_WSTR data type by default. In the Data Conversion transformation, you need to change the data type of the x_col from DT_WSTR to DT_STR.
Regards,
Mike Yin
TechNet Community Supporthow can i fix the unicode in sql command if i don't want to add data convertion in SSIS?
Tuesday, May 13, 2014 3:50 AM
-
Sign in to vote
how can i fix the unicode in sql command if i don't want to add data convertion in SSIS?
No, it is not possible. Since Unicode characters cannot be converted into non-Unicode type, if there are Unicode characters in the column, you have to use the NVARCHAR data type column. Leaving aside that whether this can be fixed in the SQL statement or not, fixing it in the SQL statement means the dynamic data types in the metadata. However, dynamic metadata is not supported natively in SSIS.
Regards,
Mike Yin
TechNet Community Support- Edited by Mike Yin Tuesday, May 13, 2014 4:51 AM
Tuesday, May 13, 2014 4:51 AM
-
Sign in to vote
how can i fix the unicode in sql command if i don't want to add data convertion in SSIS?
No, it is not possible. Since Unicode characters cannot be converted into non-Unicode type, if there are Unicode characters in the column, you have to use the NVARCHAR data type column. Leaving aside that whether this can be fixed in the SQL statement or not, fixing it in the SQL statement means the dynamic data types in the metadata. However, dynamic metadata is not supported natively in SSIS.
Regards,
Mike Yin
TechNet Community Supportyou mean i have to convert data using data convertsion in ssis to convert that column to DT_WSTR ???
Tuesday, May 13, 2014 6:15 AM
-
Sign in to vote
you mean i have to convert data using data convertsion in ssis to convert that column to DT_WSTR ???
No matter the data type of the destination column isVARCHAR or NVARCHAR, you need to avoid the dataconversion in the query. After removing the CONVERT function from the query, the output column of the OLE DB Source component is Unicode (DT_WSTR). If the destination column is of NVARCHAR column, you can directly load the data to the destination table without any data conversion.
If the destination columns is of VARCHAR data type which means that you don't need to load the Unicode data in the source table, then you need to use a Data Conversion transformationto do the data conversion and redirect the Unicode data rows. For the detailed steps, please see my initial post that I have modified right now.
If you have any questions, please feel free to ask.
Regards,
Mike Yin
TechNet Community SupportTuesday, May 13, 2014 7:25 AM