I am trying to get the last Id using max(Id) function where Id is the primary key. My code works well unless I delete last row from the table, because when I delete last row then that Id is still preserved and in that case max(Id) will retrieve the last row Id but not that Id which is deleted from the table.
Is there any function which retrieve the last row deleted Id. I have seen some posts using scope_identity()
and @@identity
functions to get the current Id. I have used these functions but they are not working. I am editing my code inside a dll file may be dat is creating problem.