Here’s how my DataTable looks like(2 columns: Name and Code):
Name Code
name1 code1
name2 code2
name3 code3
I want to insert that DataTable into an existing table named MyTable that has a primary key and those 2 columns.
I really don’t know how I should start coding my Stored Procedure, Is there any way to send as parameter a DataTable or something like that?
Thank you.
In SQL-Server 2008 you can use table valued parameters. Something like this:
Then simply pass your datatable as the value for a parameter (SqlDbType.Structured) in a SqlCommand.
Or you can use SQLBulkInsert and bypass the stored procedure.