Retrieve new identity value BEFORE inserting record into sql
Is is possible to get new values for Id (IDENTITY) before/while inserting data in a table on Button Submit - CODE level C#?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 21, 2014, 3:28 AM EST
I think this is not possible because SQL server generate Id for Identity column at the time of inserting the record.
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Jan 21, 2014, 4:42 PM EST
select max(id) from customer.
also you can get the new id after insertion using
select scope_identity()
Abhay ShankerRank #375 · 6.7K reputationPosted Jan 21, 2014, 6:48 PM EST
Select Max(Id) from table.
In coding part you need to add 1 or what ever condition you have defined in identity column