Bitwise flag that specifies one or more options to use with an instance of SqlBulkCopy.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
|Use the default values for all options.|
|Preserve source identity values. When not specified, identity values are assigned by the destination.|
|Check constraints while data is being inserted. By default, constraints are not checked.|
|Obtain a bulk update lock for the duration of the bulk copy operation. When not specified, row locks are used.|
|Preserve null values in the destination table regardless of the settings for default values. When not specified, null values are replaced by default values where applicable.|
|When specified, cause the server to fire the insert triggers for the rows being inserted into the database.|
|When specified, each batch of the bulk-copy operation will occur within a transaction. If you indicate this option and also provide a SqlTransaction object to the constructor, an ArgumentException occurs.|
The following console application demonstrates how to perform a bulk load that copies the value in the identity column of the source table to the corresponding column in the destination table, instead of generating a new value for each row's identity column.
To see how the option changes the way the bulk load works, run the sample with the dbo.BulkCopyDemoMatchingColumns table empty. All rows load from the source. Next, run the sample again without emptying the table. An exception is thrown, and the code writes a message to the console window notifying you that rows were not added because of primary key violations.
This sample will not run unless you have created the work tables as described in Bulk Copy Example Setup (ADO.NET). This code is provided to demonstrate the syntax for using SqlBulkCopy only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL INSERT … SELECT statement to copy the data.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.