When bulk copying data using native or character format, bcp, by default, converts character data to:
This can cause the loss of extended or DBCS characters during the conversion between OEM and ANSI code pages. To prevent the loss of extended or DBCS characters, bcp can create data files using:
Unicode native format and Unicode character format convert character data to Unicode during the bulk copy, resulting in no loss of extended characters.
Using the -C (code page) parameter, the bcp utility can create or read data files using the code page specified by the user. For example, to bulk copy the authors2 table in the pubs database to the Authors.txt data file using code page 850, execute from the command prompt:
bcp pubs..authors2 out authors.txt -c -C850 -Sservername -Usa -Ppassword
Alternatively, using the CODEPAGE clause, the BULK INSERT statement can read data files using the code page specified by the user. For example, to bulk copy the Authors.txt data file into the authors2 table in the pubs database using code page 850, execute from a query tool such as SQL Server Query Analyzer:
BULK INSERT pubs..authors2 FROM 'c:\authors.txt'
WITH (
CODEPAGE = 850
)
Valid values for the code page include the following.
Code page value | Description |
---|---|
ACP | Columns of char, varchar, or text data type are converted from the ANSI/Windows code page (ISO 1252) to the SQL Server code page when importing data to SQL Server, and vice versa when exporting data from SQL Server. |
OEM (default) | Columns of char, varchar, or text data type are converted from the system OEM code page to the SQL Server code page when importing data to SQL Server, and vice versa when exporting data from SQL Server. |
RAW | This is the fastest option because no conversion from one code page to another occurs. |
<value> | Specific code page number, for example, 850. |
bcp Utility | Unicode Character Format bcp |
Unicode Native Format bcp | BULK INSERT |
SetCodePage Method |