What will be BCP format for inserting a identity column

bcp
Chayan picture Chayan · Jul 5, 2010 · Viewed 11.3k times · Source

I am facing problem while I am trying to insert data to a table using BCP. The table has a identity column. I am taking input from a text file. Please let me know if there are any good solutions.

Regards, Chayan

Answer

Simon picture Simon · Oct 27, 2011

I needed to do the same thing and my colleague pointed out that you can use the -E switch on BCP to do this.

From the docs...

"-E Specifies that identity value or values in the imported data file are to be used for the identity column. If -E is not given, the identity values for this column in the data file being imported are ignored."

Works a treat, thanks Jan!