Bulk Import or export data format--Unicode character format

Source: Internet
Author: User
Tags bulk insert

Bulk Import or export data format--Unicode Character Format



Application Scenarios



When using data files that contain extended/dbcs characters to bulk transfer data between multiple instances of SQL Server , it is recommended that you use Unicode character formatting.

When you export data from a server, the Unicode character data format allows you to use a different code page than the client that performs the operation .

In this case, the use of Unicode character formats has the following advantages:

1. If the source and destination data are of type Unicode, all character data can be preserved using Unicode character format.

2. If the source and destination data types are not Unicode, use the Unicode character format to minimize the loss of extended characters in the source data that cannot be represented in the target data.

Unicode character format data files follow the conventions of Unicode files. The first two bytes of the file are hexadecimal digits 0xFFFE. These two bytes are used as byte order marks, specifying whether the high-level bytes in the file are stored in front or behind.


Important Notes

For a format file for Unicode character data files, all input fields must be Unicode text strings (that is, fixed-size Unicode strings or characters terminating Unicode strings).


The sql_variant data stored in a Unicode character format data file operates in the same way as the same data in a character format data file, except that the data is stored as nchar instead of char data.

Unicode command options for character formatting



You can use bcp, BULK Insert, or INSERT ... SELECT * from OPENROWSET (BULK ...) to import character format data into a table. For bcp commands or BULK INSERT statements, you can specify the data format on the command line. For INSERT ... SELECT * from OPENROWSET (BULK ...) statement, you must specify the data format in the format file.

The following command-line options support Unicode character formatting:

Command

Options

Description

Bcp

-W

Use Unicode character formatting.

BULK INSERT

DataFileType = 'widechar'

Unicode character formatting is used when bulk importing data.


Reference:

Https://msdn.microsoft.com/zh-cn/library/ms188289.aspx

This article is from the SQL Server deep dives blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1628101

Bulk Import or export data format--Unicode character format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.