SQL Server bulk Data Export Import Bulk INSERT use

Source: Internet
Author: User
Tags bulk insert

Brief introduction

The Bulk Insert command differs from the bcp command in that it is a SQL Server script statement that can import local or remote file data into a database in bulk, very quickly, and the remote file must be shared.

The file path must use the Universal Convention (UNC) name, which is the form of "\ \ server name or ip\ share name \ path \ file name."

Note that the remote thing here is relative to the database server, that is, if the data file is placed outside the database server, it needs to be shared with the database server;

Bulk insert typically imports data in batches with a format file exported by bcp

Bulk Insert Mate Format File syntax

Bulk Insert database name. User name. Table name
From ' Data file path '
With
(
formatfile = ' Format file path ',
FirstRow = 2--The number of rows starting in the specified data file, which is 1 by default
)

Where format files are generated using bcp

BCP SPC.dbo.BCC format nul-f c:\bcc_format.fmt-x-c-s "43.xxx.xxx.xxx"-u "sa"-P "*******"

Bulk Insert Import CSV file syntax

BULK Insert [database name. User name. Table name]
From ' Data file physical path '
With (
Fieldterminator= ', ',
Rowterminator= ' \ n '
)

CSV sample

Bulk Insert Bcc
From ' C:\\bcc.csv '
With (
Fieldterminator= ', ',
Rowterminator= ' \ n '
)

SQL Server bulk Data Export Import Bulk INSERT use

Related Article

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.