Search code examples
sql-serverbcp

How to use bcp for columns that are Identity?


I want to restore my table with BCP by code in the below.

BCP framework.att.attendance in "D:\test\mhd.txt" -T -c

But the column (id) is identity in this table.

When data is restored with BCP I want id columns to be unchanged.

In other words, if the id of the first row is '7' before BCP, I want to import data and the id of the first row will be still be '7'.

What should I do?


Solution

  • BCP IMPORT

    -E

    • -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.