SSIS: Code page goes back to 65001

房东的猫 提交于 2021-02-05 20:28:37

问题


In an SSIS package that I'm writing, I have a CSV file as a source. On the Connection Manager General page, it has 65001 as the Code page (I was testing something). Unicode is not checked.

The columns map to a SQL Server destination table with varchar (among others) columns.

There's an error at the destination: The column "columnname" cannot be processed because more than one code page (65001 and 1252) are specified for it.

My SQL columns have to be varchar, not nvarchar due to other applications that use it.

On the Connection Manager General page I then change the Code page to 1252 (ANSI - Latin I) and OK out, but when I open it again it's back to 65001. It doesn't make a difference if (just for test) I check Unicode or not.

As a note, all this started happening after the CSV file and the SQL table had columns added and removed (users, you know.) Before that, I had no issues whatsoever. Yes, I refreshed the OLE DB destination in the Advanced Editor.

This is SQL Server 2012 and whichever version of BIDS and SSIS come with it.


回答1:


65001 Code page = Unicode (UTF-8)

Based on this Microsoft article (Flat File Connection Manager):

Code page
Specify the code page for non-Unicode text.

Also

You can configure the Flat File connection manager in the following ways:

Specify the file, locale, and code page to use. The locale is used to interpret locale-sensitive data such as dates, and the code page is used to convert string data to Unicode.

So when the flat file has a Unicode encoding:

  • Unicode, UTF-8, UTF-16, UTF-32

Then this property cannot be changed, it will always return to it original encoding.

For more infor about the Code Page identifiers, you can refer to this article:

  • Code Page Identifiers



回答2:


If it is a CSV file column text stream [DT_TEXT] to SQL varchar(max) data type that you want to convert to, change the flat file Connection Manager Editor property Code page to 1252 (ANSI - Latin I).




回答3:


If it's a csv file, you can still use code page 1252 to process it. When you open the flat file connection manager it shows you the code page for the file, but you don't need to save that setting. If you have other changes to make in the connection manager, change the code page back to 1252 before you save the changes. It will process fine if there are no unicode characters in the file.




回答4:


I solved this in SSIS through Derived Column Transformation

Derived Column



来源:https://stackoverflow.com/questions/48454336/ssis-code-page-goes-back-to-65001

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!