CipherIS
asked on
.NET SQLBulkCopy
I have a question about SQLBulkCopy. Looking at the below code: When setting the DestinationTableName does that create a table in SQL Server? I understand that once the DestinationTableName is set then WriteToServer will BulkCopy data in the DataTable to the DestinationTableName.
SqlBulkCopy sqlcpy = new SqlBulkCopy(mySQLConnectio n);
sqlcpy.DestinationTableNam e = "myTable"
sqlcpy.WriteToServer(dt);
Any other info that I would need to be aware of is greatly appreciated.
Thanks
SqlBulkCopy sqlcpy = new SqlBulkCopy(mySQLConnectio
sqlcpy.DestinationTableNam
sqlcpy.WriteToServer(dt);
Any other info that I would need to be aware of is greatly appreciated.
Thanks
Hi!
More Info on destination Table
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.
Thanks!
More Info on destination Table
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>
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.
Thanks!
ASKER
The question I'm asking is does setting the DestinationTableName in .NET create a table in SQL Server?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DestinationTableName = Table in the database where you are going to load/copy the bulk data
this table(mytable) in Database and Dataset table (dt)
should have proper table mapping
Thanks!