Bulk import SQL Server with UTF-8 data format file

I link to the following page:

http://msdn.microsoft.com/en-us/library/ms178129.aspx

I just want the array to import some data from a file with Unicode characters. I tried to encode the actual data file in UC-2, UTF-8, etc., but nothing works. I also changed the format file to use SQLNCHAR , but still it does not work and gives an error:

Bulk upload data conversion error (truncation) for row 1, column 1

I think this is due to this statement from the link above:

For a format file that will work with a Unicode character data file, all input fields must be Unicode text strings (that is, fixed or Unicode character strings).

What exactly does this mean? I thought this means that each character string should be fixed 2 bytes, which should encode the file in UCS-2 ???

+4
source share
2 answers

This blog post was really helpful and solved my problem:

http://blogs.msdn.com/b/joaol/archive/2008/11/27/bulk-insert-using-unicode-data-files.aspx

Something else needs to be noted - the Java class generated the data file. For the work on this solution to work, the data file had to be encoded in UTF-16LE , which can be set in the constructor of OutputStreamWriter (for example).

+6
source

In SQL Server 2012, I imported a CSV file saved using Notepad ++ registered in UCS-2 with special Spanish characters

0
source

Source: https://habr.com/ru/post/1398305/


All Articles