Question
· Mar 9, 2022

How to preserve identity field value in target system same as source when we restored/import data from 2019 to 2021

Hi Team,

When I restored the database or import the data from source system to target system at that time how to Preserve source system identity value in target system.

Thanks,

Ankur Shah

Discussion (2)0
Log in or sign up to continue

Ankur,

If you use the Backup and Restore functionality (^DBACK and ^DBREST) all identity values will be preserved.

If you are importing the data in another way you need to look at the $SYSTEM.SQL SetIdentityInsert ClassMethod, this allows you to insert id values when importing data through SQL statements for example.

Oliver.

Oliver already pointed you at the key setting for this, but I thought I'd include a snippet from and link to the corresponding doc as well

If Source has a foreign key public RowID, and you want Destination to have the same foreign key relationship, you must define Destination with the ALLOWIDENTITYINSERT=1 parameter. When defining Destination as a persistent class, specify Parameter ALLOWIDENTITYINSERT=1;. When using CREATE TABLE to define Destination, specify %CLASSPARAMETER ALLOWIDENTITYINSERT=1. If a table is defined as ALLOWIDENTITYINSERT=1, this setting cannot be changed by the SetOption("IdentityInsert") method.