I have an autogenerated column ID in my table class. While inserting i want to fetch the value of auto ID which is suppose to be generated for that column while inserting and concat to a value to be put in REF column which is a 6 digit unique key.
How can i find the ID of next column to be generated, it is easy to add a 1 to the previous ID but what if the previous id is deleted? please help me to understand how to go about this issue.
I dont want the ID of deleted item to be given to a fresh item.
You can use SCOPE_IDENTITY() to get the last created identity value in your current scope. The next value will be incremented from that, but you can’t be sure that it will be in your scope, another scope or what. Deletions do not affect what the next value will be.
Why would you need the “next value”?