The information in this article applies to:
SUMMARYThe bulk copy program (BCP) utility included with SQL Server 7.0 works differently from the BCP utility included with previous versions of SQL Server. These changes can have an effect on code page conversion during bulk copy operations. This article describes those changes and provides examples of code page conversion to clarify the issues involved. MORE INFORMATION
Previous versions of the BCP utility were based on the DB-Library API. Character code translation between ANSI and OEM code pages was determined by the AutoAnsiToOem client configuration setting. This setting was disabled by default in SQL Server 4.21a and enabled by default in SQL Server 6.0 and 6.5. However, the character code translation was only enabled when data was copied from OEM clients to ANSI SQL Servers or from ANSI clients to OEM SQL Servers. No character code conversion would occur if AutoAnsiToOem was disabled or if data was being transferred between an OEM server and an OEM client.
If you used a previous version of BCP with an ANSI SQL Server and AutoAnsiToOem enabled, you do not need to use the /C switch. If you used previous versions of BCP with AutoAnsiToOem disabled or against an OEM SQL Server, you can disable automatic character code conversion using the /CRAW parameter with BCP for SQL Server 7.0. In order for BCP for SQL Server 7.0 to convert to or from a given code page, that code page must be installed on the client. For information about how to install additional code pages, please see the following article in the Microsoft Knowledge Base: Q177561 HOWTO: Add and Enable Additional Languages in Windows NT The /C parameter only applies when copying character data types in character (/c) or native modes (/n). It has no effect when using Unicode data types by including the /w or /N arguments. The remainder of this article provides some examples to help illustrate these concepts. Example 1SQL Server code page 1252 and client OEM code page 437:At the command line, type:
Because the client's OEM code page is 437, BCP will interpret the character code for the characters in the Authors.txt input file using the 437 code page and convert to the code for the equivalent character in the 1252 code page. If the Authors.txt file was saved as code page 437 character data, the import will succeed. However, if the file contains data from some other code page (for example, the file was exported from a SQL Server using code page 850), extended characters may be incorrectly translated. As an example, if Authors.txt contains character data from an 850 code page (where the yen symbol is character code 190), it would be incorrectly interpreted as the character associated with code 190 in the 437 code page and translated incorrectly into SQL Server. To perform the correct translation, you would use the -C850 switch to ensure that the code page 850 characters were correctly interpreted so that they could be translated to the ANSI code page equivalent (where the yen symbol is character code 165). Keep in mind that even if the file does contain code page 437 character data, some characters may be lost if there is not an equivalent character in the 1252 code page. Example 2SQL Server code page 932 and client with OEM code page 850:At the command line, type:
BCP will attempt to convert the code page 932 character data to the client's code page 850 before saving it to the data file. Because some characters in the 932 code page do not exist in code page 850, data may be lost in this transfer. You would need to add the /CRAW option to prevent any character translation. This is different behavior from previous versions of SQL Server where BCP would not convert characters between OEM SQL Servers and OEM clients. Example 3SQL Server with code page 850 and client with code page 437:At the command line, type:
BCP will not attempt to convert the data, and it will be saved in its original code page. Alternatively, -C850 could be specified, although this would require that code page 850 be installed on the client. However, extended characters in the data will not appear correctly when viewed on this client because the data is stored as code page 850 character data and the client's code page is 437. If you want to import this file into another SQL Server using BCP, you would need to add the /C850 option so that the characters would be correctly translated into the destination SQL Server. Use the /CRAW option only if the destination SQL Server is using the 850 code page. If you do not use the /C switch, the characters in the file will be interpreted according to the 437 client code page and extended characters may be improperly imported into SQL Server. Example 4SQL Server 7.0 with code page 850 and client with code page 437; file contains characters exported from a SQL Server 6.5 with code page 1252 where AutoANSItoOEM was disabled:At the command line, type:
BCP will use code page 1252 to interpret the characters in the Authors.txt file. All extended characters that exist in the 850 code page will be converted properly. If you did not use the /C switch, the characters in the file would be incorrectly interpreted using the 437 client code page. ReferencesFor additional information, please see the following article(s) in the Microsoft Knowledge Base:Q153449 INF: SQL Server Code Pages and AutoAnsiToOem Behavior Q165051 INF: Installing a DBCS Code Page for SQL Server Q177561 HOWTO: Add and Enable Additional Languages in Windows NT Additional query words: cp international language codepage codepages win 9x win9x win95 win98 winnt
Keywords : SSrvBCP |
Last Reviewed: May 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |