How to insert a DataTable with existing Key to a SQL Server Table.

Posted by user296575 on Stack Overflow See other posts from Stack Overflow or by user296575
Published on 2010-03-18T14:06:42Z Indexed on 2010/03/18 14:11 UTC
Read the original article Hit count: 414

Filed under:
|
|
|
|

I am working with VB.NET.. i have a DataTable called "QUESTION", containing 3 fields:

  • QuestionNumber (unique integer key)
  • QuestionText
  • QuestionType

In my SQL Server database I created a Table called "QUESTION" with the same fields. QuestionNumber is defined as integer unique key, auto increment

Now, when i make a bulk copy to insert the DataTable into the SQL Server, the database overwrites my QuestionNumber from the DataTable and generates new ones (starting from 1 increment 1).

How do i have to change my database setup, that the original QuestionNumbers are copied into the database?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about sql