SQL Server – Import Export Wizard – Enable Identity Insert

I had requirement to move the data from source table with his identity column to destination table that have also identity column.

Identity columns are commonly used as primary keys in database tables. These columns automatically assign a value for each new row inserted. Identity column does not allow any kind of insertion from the user.

Before starting I was thinking I need to enable the IDENTITY_INSERT on the destination table by using

SET IDENTITY_INSERT myTable ON   and once I will move the data then will OFF the IDENTITY_INSERT by using SET IDENTITY_INSERT myTable OFF.

When I checked the SQL Server – Import Export Wizard then I checked that there is one option “Enable Identity Insert” that made my task easy.

SQL Server – Import Export Wizard – Enable Identity Insert

SQL Server – Import Export Wizard – Enable Identity Insert

If we enable that option (i.e. Enable Identity Insert) it allows the values to be inserted in the identity field. This way, the exact identity values are moved from source database to destination table.

2 comments