SUPPOSE I HV TABLE1 WHICH CONTAINS ID AS PK
N IF I DELETE THE ENTRY SAY FOR ID 2 N 3
NOW D NEXT ID WHICH IS GOING TO INSERT IS 4
SO NOW I WANT TO KNOW THAT ID NO BEFORE ITS INSERTION IN TABLE
MAX PRIMARY KEY VALUE
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 22, 2011, 10:14 PM EDT
This happen because your PK column is Identity there fore it increaments column count by while inserting by considering deleted value also.....But................
there is solution for it as you want you can get maximum inserted value that column even considering deleted vaule by below line
SELECT IDENT_CURRENT('YourTable Name')
Hope it will solve your problem .
Thanx
Pravin
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 22, 2011, 10:13 PM EDT
SELECT IDENT_CURRENT('TableName')
Amol183 reputationPosted Sep 24, 2011, 7:38 AM EDT
Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 25, 2011, 8:08 PM EDT
Thanx,
Pravin.