Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Copy out and error files [Table of Contents] How bcp differs from other utilities

Utility Guide

[-] Chapter 3 Using bcp to Transfer Data to and from Adaptive Server
[-] Data integrity: defaults, rules, and triggers

Data integrity: defaults, rules, and triggers

To ensure integrity, bcp handles data to copy depending upon its element.

Defaults and datatypes

When copying data into a table, bcp observes any defaults defined for the columns and datatypes. That is, if there is a null field in the data in a file, bcp loads the default value instead of the null value during the copy.

For example, here are two rows in a file to be loaded into authors:

409-56-7008,Bennet,David,415 658-9932,622 Pine St.,Berkeley,CA,USA,94705213-46-8915,Green,Marjorie,,309 63rd St. #411,Oakland,CA,USA,94618

Commas separate the fields; a newline terminator separates the rows. There is no phone number for Marjorie Green. Because the phone column of the authors table has a default of "unknown," the rows in the loaded table look like this:

409-56-7008  Bennet  David 415 658-9932  622 Pine St.
    Berkeley  CA  USA  94705
213-46-8915  Green   Marjorie  unknown       309 63rd St. #411
    Oakland   CA  USA  94618

Rules and triggers

bcp, to enable its maximum speed for loading data, does not fire rules and triggers.

To find any rows that violate rules and triggers, copy the data into the table and run queries or stored procedures that test the rule or trigger conditions.


Copy out and error files [Table of Contents] How bcp differs from other utilities