SqlBulkCopy::DestinationTableName Property

 

Name of the destination table on the server.

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

public:
property String^ DestinationTableName {
	String^ get();
	void set(String^ value);
}

Property Value

Type: System::String^

The string value of the DestinationTableName property, or null if none as been supplied.

If DestinationTableName has not been set when WriteToServer is called, an ArgumentNullException is thrown.

If DestinationTableName is modified while a WriteToServer operation is running, the change does not affect the current operation. The new DestinationTableName value is used the next time a WriteToServer method is called.

DestinationTableName is a three-part name (<database>.<owningschema>.<name>). You can qualify the table name with its database and owning schema if you choose. However, if the table name uses an underscore ("_") or any other special characters, you must escape the name using surrounding brackets as in ([<database>.<owningschema>.<name_01>]). For more information, see "Identifiers" in SQL Server Books Online.

You can bulk-copy data to a temporary table by using a value such as tempdb..#table or tempdb.<owner>.#table for the DestinationTableName property.

The following console application demonstrates how to bulk load data using a connection that is already open. The destination table is a table in the AdventureWorks database.

In this example, the connection is first used to read data from a SQL Server table to a SqlDataReader instance. The source data does not have to be located on SQL Server; you can use any data source that can be read to an IDataReader or loaded to a DataTable.

System_CAPS_importantImportant

This sample will not run unless you have created the work tables as described in Bulk Copy Example Setup. 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.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: