Reputation: 410
Ok.. a silly litte question. Honestly, it's not important for what I'm doing, but I've just gotta know!
I created a table with an IDENTITY(1,1) column. I insert no rows. I used
DBCC CHECKIDENT(table, RESEED, 10000)
I run the following:
SELECT IDENT_CURRENT('table')
SELECT last_value, seed_value
FROM sys.identity_columns
WHERE [object_id] = OBJECT_ID('table');
The first returns 10000. The second returns NULL, 1 (the original seed value).
Where is 10000 stored?
Upvotes: 1
Views: 121
Reputation: 453278
This is not documented and is subject to change but it is stored in the left most X bytes of idtval
in sys.syscolpars
.
The value of X
depends on the datatype of the underlying column. For an int
it is 4.
Immediately after running
CREATE TABLE [table1](Foo int IDENTITY)
The following query (only can be executed using the DAC) ...
SELECT *,
CAST(CAST(REVERSE(LEFT(idtval, 4)) AS BINARY(4)) AS INT)
FROM sys.syscolpars
WHERE id = OBJECT_ID('table1')
... Returns
After running
DBCC CHECKIDENT([table1], RESEED, 10000)
It returns
Upvotes: 1