![]() | ![]() |
Home |
|
|
Utility Guide |
|
| Chapter 3 Using bcp to Transfer Data to and from Adaptive Server |
|
| Examples: copying out data interactively |
|
| Copying out data with delimiters |
In the following examples, bcp copies data interactively from the publishers table to a file.
For information about format files, see "Using format files".
Comma-delimited, newline-delimited with format fileThe first example creates an output file with commas between all fields in a row and a newline terminator at the end of each row. This example creates a format file (pub_fmt) that you can use later to copy the same or similar data back into Adaptive Server.
bcp pubs2..publishers out pub_out
The results as stored in the pub_out file are:
0736,New Age Books,Boston,MA 0877,Binnet & Hardley,Washington,DC 1389,Algodata Infosystems,Berkeley,CA
The contents of the pub_fmt format file are:
10.0 4 1 SYBCHAR 0 4 "," 1 pub_id 2 SYBCHAR 0 40 "," 2 pub_name 3 SYBCHAR 0 20 "," 3 city 4 SYBCHAR 0 2 "\n" 4 stateTab-delimited with format file
Similarly, the following example creates tab-delimited output from the table pubs2..publishers in the pub_out file.
bcp pubs2..publishers out pub_out
The results as stored in the pub_out file are:
0736 New Age Books Boston MA 0877 Binnet & Hardley Washington DC 1389 Algodata Infosystems Berkeley CA
The contents of the pub_fmt format file are:
10.0 4 1 SYBCHAR 04 "\t" 1 pub_id 2 SYBCHAR 040 "\t" 2 pub_name 3 SYBCHAR 020 "\t" 3 city 4 SYBCHAR 02 "\n" 4 state
|
|