Sample BCP Scripts

This section describes how to use BCP to perform typical import and export routines. The examples discussed in this section use the pubs..discounts table.

The following is the structure of the discounts table:

discounttype varchar (40) 
stor_id varchar
lowqty smallint
highqty smallint
discount decimal(4, 2)

The following is discounts table data:

discounttype                             stor_id lowqty highqty discount 
---------------------------------------- ------- ------ ------- --------
Initial Customer                         (null)  (null) (null)  10.50
Volume Discount                          (null)  100    1000    6.70
Customer Discount                        8042    (null) (null)  5.00
					

Simple Import

This example uses the -c switch to load a data file that contains tab-delimited fields and newline-delimited rows. For this example, ...

Get Microsoft® SQL Server™ 2000 DBA Survival Guide, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.