.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(mySQLConnection);
sqlcpy.DestinationTableName = "myTable"
sqlcpy.WriteToServer(dt);

Any other info that I would need to be aware of is greatly appreciated.

Thanks
LVL 2
CipherISAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NavneetSoftware EngineerCommented:
HI!

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!
0
NavneetSoftware EngineerCommented:
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!
0
CipherISAuthor Commented:
The question I'm asking is does setting the DestinationTableName in .NET  create a table in SQL Server?
0
NavneetSoftware EngineerCommented:
NO, The table need to exists in Database.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.