Recently while developing several applications, I came across a problem where my current solution seems very error prone. I want to display the current autonumber seed in an SQL Server's DB Table. For instance, an autonumber column's last item is 746, I want the "Add Form" to display 747.
My current solution is to get the last entered item's number and add 1 to it like so:
SELECT Top 1 autonumber from table1 Order by autonumber DESC
That in return gives me the int 746. I then add 1 to make it 747 and display it on the form. However the problem is, if the item is deleted from the database then the query would return 745, but the DB seed will still be 746. Is there a way to query the autonumber seed directly to display that, instead of querying the value of the autonumber column?
My program is in C# but I'm not sure if this question would be better answered in the databases forum. Please forgive me if it was placed in the incorrect forum.
This post has been edited by lando786: 27 June 2011 - 10:05 AM