Insert for Id (Primary key) column without keeping it as identity
Using the SPARK framework , I need to specify custom int value during insert, for an Id column of a table, which is a primary key.
The need for this is, because Id is generated in different database and referred in multiple tables of another db , value of which is required to be kept consistent. This Id column in a database has a reference to multiple tables hence can not be created as an additional column to store the value.
Please suggest how to.
Lauren Kruglak, Nov 17, 2014
Yes, it is possible to forcibly insert a particular identity value.
However, I am not sure how your table is setup and how you avoid interference with other identity values.
You simple build out your SQL statement and surround it by two SET IDENTITY_INSERT settings.
Below we are adding a student with Id = 812.
Hope this helps.
Jack Poorte, Nov 21, 2014