Basic BCP Usage
BCP as it’s name suggest is used for 1 purpose the bulk copy of data to and from Sybase Tables. To utilize the utility the basic command format is:bcp DATABASE..TABLE out C:DBtemp.txt
 | 
BCP Option Flags
In addition to the command there are a few options you may also find yourself using.- Server Flag -S You can specify the Database Server you are accessing by use of the -S flag followed by the Server. (e.g. -S SYBABC )
 - User Flag -U If you are not using credentials outlined in your .ini file then you can specify the User you would like to use for authentication using the -U flag followed by the user name. (e.g. -U guest)
 - Password Flag -P If no password is supplied then a prompt will occur to input it. You can use the -P flag to specify the password to use to bypass the prompt. (e.g. -P test123)
 - Native Format -n To export data in native format which is not readable by looking directly at the file you can use the -n flag. This mode will make it so you don’t have to specify the column format during export.
 - Char Format -c To export all data in basic char format then you can use the -c flag. This mode will also make it so you don’t have to specify the column format during export.
 - Tab Format -t The default format for delimiting data columns per row is the tab character to specify a different delimiter -t can be used followed by the new delimiter.
 - Row Format -r If you want to have a different delimiter then the new line character in your export you can modify it by using the -r flag followed by the new delimiter.
 
Basic BCP Output Example
bcp DATABASE..TABLE out C:DBtemp.txt -c -S server -U userName -P password
 | 
Basic BCP Input Example
bcp DATABASE..TABLE inC:DBtemp.txt -c -S server -U userName -P password
 | 
Resources
- Sybase Online Manual – BCP Utility Guide
 - http://mdbitz.com/2010/04/22/using-the-bcp-utility-to-input-and-output-data-tofrom-sybase/
 
No comments:
Post a Comment