Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 766
Binary Worrier Avatar asked Dec 07 '22 01:12

Binary Worrier


2 Answers

SELECT IDENT_CURRENT('MyTable')

See BOL

like image 189
AdaTheDev Avatar answered Dec 09 '22 15:12

AdaTheDev


SELECT IDENT_CURRENT('TABLE_NAME')

returns NULL if there is no identity defined in the table

like image 20
il_guru Avatar answered Dec 09 '22 14:12

il_guru