Click here to Skip to main content
15,846,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to find max seed of an identity column if table has no rows(i.e. empty).

e.g. if a table has 10 rows ,the max identity will be 10 in case of(1,1) ,If we delete all rows of table and re-insert a row ,the identity will be 11. In this case i want to find out identity values 10(max identity) no matter table is empty.

Please help


You can use the below function -


Instead of ProductMaster pass your table name
Share this answer
Ankur\m/ 15-Oct-13 7:37am    
Correct, 5!
Member 7790559 16-Oct-13 7:37am    
Thanks for solution
You can also use - DBCC CHECKIDENT (Transact-SQL)[^] to check the current identity value and change it, if required.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900