Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 constraint

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2006-12-16 : 00:08:27
how constraint can be implemented in T-SQL statement while making batch insert

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-16 : 09:10:06
in 2005 BOL an entry for Bulk insert states:
quote:

CHECK_CONSTRAINTS
Specifies that all constraints on the target table or view must be checked during the bulk-import operation. Without the CHECK_CONSTRAINTS option, any CHECK constraints are ignored, and after the operation, the constraint on the table is marked as not-trusted.

Note:
UNIQUE, PRIMARY KEY, FOREIGN KEY, or NOT NULL constraints are always enforced.

At some point, you must examine the constraints on the whole table. If the table was non-empty before the bulk-import operation, the cost of revalidating the constraint may exceed the cost of applying CHECK constraints to the incremental data.

A situation in which you might want constraints disabled (the default behavior) is if the input data contains rows that violate constraints. With CHECK constraints disabled, you can import the data and then use Transact-SQL statements to remove the invalid data.

Note:
The MAXERRORS option does not apply to constraint checking.

Note:
In SQL Server 2005, BULK INSERT enforces new data validation and data checks that could cause existing scripts to fail when they are executed on invalid data in a data file.





Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -