Edit:
After spending several hours comparing entire page dumps, I realized that there is an easier way and I have to stay on DMV.
The value saves backup / restore, which is a clear indication that it is stored - I dumped all the pages in the database and could not find the location / change when the record was added. Comparing 200k lines of page dumps is not fun.
I used a special admin console. I took a dump of each open internal table inserted in a row, and then made another dump of the system tables. Both of these dumps were identical, which indicates that while he survived and, therefore, should be stored, he is not exposed even at this level.
So, having walked around in a circle, I realized that the DMV has an answer.
create table foo (MyID int identity not null, MyField char(10)) insert into foo values ('test') go 10 -- Inserted 10 rows select Convert(varchar(8),increment_value) as IncrementValue, Convert(varchar(8),last_value) as LastValue from sys.identity_columns where name ='myid' -- insert another row insert into foo values ('test') -- check the values again select Convert(varchar(8),increment_value) as IncrementValue, Convert(varchar(8),last_value) as LastValue from sys.identity_columns where name ='myid' -- delete the rows delete from foo -- check the DMV again select Convert(varchar(8),increment_value) as IncrementValue, Convert(varchar(8),last_value) as LastValue from sys.identity_columns where name ='myid' -- value is currently 11 and increment is 1, so the next insert gets 12 insert into foo values ('test') select * from foo Result: MyID MyField ----------- ---------- 12 test (1 row(s) affected)
Just because the rows were deleted, the last value was not reset, so the last value + increment should be the correct answer.
And I'm going to write an episode on my blog.
Oh, and a short cut on all of this:
select ident_current('foo') + ident_incr('foo')
Thus, it actually becomes easy - but it all assumes that no one else used your identifier until you returned it. Good for research, but I would not want to use it in code.