Exporting data to csv from SQL Server

v8wbuo2f  于 2023-04-19  发布在  SQL Server
关注(0)|答案(2)|浏览(204)

I have a SQL Server table that contains columns of type varchar(MAX) and I'm trying to get a .csv (UTF-8) type export but I get this error instead.

I want to know how I can change this data type to nvarchar(MAX) without losing data. Can anyone help?

Messages
Error 0xc00470d4: Data Flow Task 1: The code page on Destination - test_csv.Inputs[Flat File Destination Input].Columns[test1] is 1252 and is required to be 65001.
(SQL Server Import and Export Wizard)

Error 0xc00470d4: Data Flow Task 1: The code page on Destination - test_csv.Inputs[Flat File Destination Input].Columns[test2] is 1252 and is required to be 65001.
(SQL Server Import and Export Wizard)

(many more of the same error - for each column)

Error 0xc004700c: Data Flow Task 1: One or more component failed validation.
(SQL Server Import and Export Wizard)

Error 0xc0024107: Data Flow Task 1: There were errors during task validation.
(SQL Server Import and Export Wizard)

I have looked into similar questions , where I have the same problem but I don't know how to use CAST or CONVERT in the query

67up9zun

67up9zun1#

You can solve this in 3 ways:

  • CAST your source columns to NVARCHAR in the initial SELECT , e.g. CAST(mycolumn as nvarchar(column_length))
  • Use a SSIS Data Conversion task to convert the strings to Unicode
  • Set Flat File Connection Manager's code page to '1252 ANSI - Latin I'

(65001 Code page = Unicode (UTF-8))

You might find that the 3rd option is easiest.

zpjtge22

zpjtge222#

You should enable Unicode with the checkbox next to the Locale:

相关问题