Bulk Insert Using Unicode Big-Endian Problems
Feb 27, 2008I have been racking my brain over this hopefully someone has run into a similar issue. I am attempting to Bulk insert several Unicode (UCS-16BE) data files that are missing their Unicode Signature. If I add a Big-Endian signature (FE FF) I can get the files to load into a table without using a format file, but if I attempt to use a format file I get the following error ( I need to use a format file due to more columns in the actual table than in the file):
Msg 4832, Level 16, State 1, Line 1
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
If I attempt to load without the Unicode signature, with a format file the correct number of characters load into the fields, but the data is all €˜€™s. I have tried various codepages (including 1201 & 1200) and codepage settings and none have any effect on the data that is loaded or not loaded.
Code Using Format File:
BULK INSERT [ARE_Test_Stage].[dbo].LFBK
FROM 'U:ProjectsTempUnicodeTest2 est-w.TXT'
WITH (
DATAFILETYPE = 'widechar',
CODEPAGE = '1201',
MAXERRORS = 2147000000,
FORMATFILE = 'U:ProjectsTempUnicodeTest2FormatFiles est-w_METADATA.fmt',
KEEPNULLS
)
Format File:
9.0
14
1 SQLNCHAR 0 6 "