I have noticed that SQL keeps track of the latest identity (field it automatically increments each time a new record is created). I want to retrieve the latest identity from the table using C#. Unfortunately most of the time the table is empty (records are written and removed after a while, so often the table is empty).
Is this possible to do this within the bounds of the C# SQL API or do I have to create a stored procedure to retrieve this?

To better explain. If the row above was removed, the next ID number for the next record would be 32. I want to retrieve 32 before the record is written in, in the situation where the table is empty.
http://msdn.microsoft.com/en-us/library/ms175098.aspx
However, although this shows what the next ID will be, this doesn’t always mean it will be the next ID entered by yourself. Someone else could
INSERTa new record before you.In short, there is no way of returning the value of what you will next be inserting.