0

Where does the Ident_Current() get its return value?

I would like to find the system table(s) that hold identity values. Any information on HOW ident_current works would also be helpful.

Please note that I understand what ident_current does, I just don't know where it gets its value or how it does it.

Thanks in advance.

bsivel
  • 2,821
  • 5
  • 25
  • 32

1 Answers1

3

You can't do exactly what IDENT_CURRENT() does because what it does is not officially documented. You can get the same answer - simulating what IDENT_CURRENT() does - from:

SELECT COALESCE(last_value, seed_value)
  FROM sys.identity_columns
  WHERE [object_id] = OBJECT_ID('dbo.tablename'));

Which I answered in your other question 10 minutes ago.

If you want to test how fast IDENT_CURRENT is, then test IDENT_CURRENT, don't try to simulate its functionality, because that won't necessarily be a valid test of what IDENT_CURRENT does (for example, it can probably retrieve these from memory, while you can't).

Community
  • 1
  • 1
Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
  • Aaron - Thank you for the information - this is what I was looking for. I marked the question as answered. – bsivel Apr 16 '13 at 17:56