Many times we need to know what is the current identity of the column. I have found one of my developer using aggregated function MAX() to find the current identity.
USE AdventureWorks
GO
SELECT MAX(AddressID)
FROM Person.Address
GO

However, I prefer following DBCC command to figure out current identity.
USE AdventureWorks
GO
DBCC CHECKIDENT ('Person.Address')
GO

Reference : Pinal Dave (http://blog.SQLAuthority.com)




hi,
i tried it but it gives me error.
but when i am just giving the table name it gives the correct result
i think it should be like this
USE Name_Of_The_DB
GO
DBCC CHECKIDENT (‘Name_Of_The_Table’)
GO
please check as when i given the column name it gives me error
What is Person.Address???
i didnot get it plz help………..
even SELECT IDENT_CURRENT(’table name’) gives the desired results
or we can use @@identity
@@Identity will not work. it will give the the last identity inserted in a transaction. i ll go with krishna.