18.1. BCP Utility
BCP runs from an operating system command prompt to import or export native data (specific to SQL Server), ASCII text, or Unicode text. This means that you can execute BCP from an operating system batch file or user-defined stored procedure, as well as from other places. BCP can also be run as part of a scheduled job, or executed from a .NET object through the use of a shell command.
Like most command-line utilities, options can be specified using a hyphen (-) or forward slash (/); however, unlike most DOS or Windows family utilities, option switches are case sensitive.
18.1.1. BCP Syntax
bcp {[[<database name>.][<owner>].]{<table name>|<view name>}|"<query>"} {in | out | queryout | format} <data file> [-m <maximum no. of errors>] [-f <format file>] [-x] [-e <error file>] [-F <first row>] [-L <last row>] [-b <batch size>] [-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6] [-q] [-C <code page> ] [-t <field term>] [-r <row term>] [-i <input file>] [-o <output file>] [-a <packet size>] [-S <server name>[\<instance name>]] [-U <login id>] [-P <password>] [-T] [-v] [-R] [-k] [-E] [-h "<hint> [,...n]"]
Geez — that's a lot to take in, so let's go through these switches one by one (thankfully, most of them are optional, so you will usually only include just a fraction of them).
NOTE
Note that many of the switches for the BCP utility are case sensitive — often, a given letter has an entirely different meaning between cases.
Parameter | Description |
---|---|
Database name | Exactly what it ... |
Get Professional SQL Server™ 2005 Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.