Bulk Import and export data--Introduction

Source: Internet
Author: User

Bulk Import and export data-- Introduction


SQL Server supports bulk export of data from SQL Server tables and import of bulk data into SQL Server tables or unpartitioned views. Bulk Import and bulk export are important to effectively transfer data between SQL Server and heterogeneous data sources.

"Bulk export" refers to copying data from a SQL Server table to a data file.

"Bulk import" refers to loading data from a data file into a SQL Server table.

For example, you can export data from a Microsoft Excel application to a data file, and then bulk import the data into a SQL Server table.

Ways to bulk import and export data


You can use the following basic methods:

Method

Description

Import data

Exporting data

bcp utility

A command-line utility (Bcp.exe) that bulk exports data and bulk-import data and generates a format file.

Support

Support

BULK INSERT Statement

Transact-SQL statements that import data directly from a data file into a database table or an unpartitioned view.

Support

Not supported

INSERT ... SELECT * from OPENROWSET (BULK ...) statement

Use the OPENROWSET bulk rowset provider to bulk import data into SQL SERVER tables Transact-SQL statements by specifying the OPENROWSET (BULK ...) function in the INSERT statement to select the data.

Support

Not supported


Format file


bcp utility, BULK Insert, and insert ... SELECT * from OPENROWSET (BULK ...) supports the use of specialized "format files" to store formatting information for each field in the data file. The format file can also contain information about the appropriate SQL Server tables. A format file can be used to provide all the format information that is required to bulk export data from a SQL Server instance and to bulk import data into it.

The format file provides a flexible way to interpret the data in the data file during import and to set the data format in the data file during export. This flexibility allows you to interpret data without having to write specialized code or to reformat the data to meet the special needs of SQL Server or external applications. For example, if you bulk export the data you want to load to an application that requires a comma-separated value, you can use a format file to insert a comma as a field terminator into the exported data.

SQL Server supports two types of format files: XML format files and non-XML format files.

The bcp utility is the only tool that can generate a format file.

preparing for SQL Server data requirements for bulk export or import

For SQL Server bulk export or imported data is required in a format that is detailed in the specific instructions for MSDN:

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

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

Bulk Import and export data--Introduction

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.