Solved

bcp is not following the check constraint

Posted on 1998-08-25
2
610 Views
Last Modified: 2006-11-17
Hi,

I have a check constraint on several columns of integers.  When I use bcp, even when the values being imported are outside the specified domain, bcp imports them in just fine.
When I use an insert statement manually, the constraints are enforced, so I don't think it's my syntax.

How can I get bcp to follow the check constraints and not go outside my desired domain?

A part of my create table statement:
num_5000   INTEGER   NOT NULL
    CHECK (num_5000 BETWEEN 0 and 708),

The bcp command for a tab delimited ASCII text file:
bcp chiptray..core_data in temp.txt /SSERVER /Usa /Pxxx /c

And finally, bcp is called from within a batch file.

Thanks.  :-)
0
Comment
Question by:atclark
2 Comments
 
LVL 3

Accepted Solution

by:
gmoriak earned 50 total points
ID: 1089745
I'm sorry, but BCP can't be made to check constraints.

BCP is so quick because it ignores things like constraints and triggers.  You have three options as I've learned.

1.  BCP into an alternate table and create a process to transfer items to your real table.  This process (sp, insert/select,  etc.) will use the constraints.
2.  Create a process to check and report constraint violations after BCP.
3.  Say oh well and live with constraint violations or change the process that creates the input file to enforce constraints so there are no problems
0
 

Author Comment

by:atclark
ID: 1089746
Thank you.  That's exactly the information I needed.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
T-SQL 10 36
Download ms sql express. 2 28
SQL Availablity Groups Shared Path 2 16
interpreting data from function COLUMNS_UPDATED 2 18
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question