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#?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Jan 21, 2014, 11:48 PM
Select Max(Id) from table.
In coding part you need to add 1 or what ever condition you have defined in identity column
Biswa Pujarini MohapatraPosted Jan 21, 2014, 9:42 PM
select max(id) from customer.
also you can get the new id after insertion using
select scope_identity()
Jignesh TrivediPosted Jan 21, 2014, 8:28 AM
I think this is not possible because SQL server generate Id for Identity column at the time of inserting the record.