How to 'select' the current identity value for a table?

Binary Worrier picture Binary Worrier · Oct 28, 2010 · Viewed 7.2k times · Source

dbcc checkident (MyTable, NORESEED)

Will show the identity value in a message. I can't see the message as I need to select the identity value through a DataReader.

Anyone any ideas?

Thanks folks

Answer

AdaTheDev picture AdaTheDev · Oct 28, 2010
SELECT IDENT_CURRENT('MyTable')

See BOL