For autoincrement fields: MAX(ID) vs TOP 1 ID ORDER BY ID DESC

后端 未结 7 1263
甜味超标
甜味超标 2020-12-06 10:20

I want to find the highest AutoIncremented value from a field. (its not being fetched after an insert where I can use @@SCOPE_IDENTITY etc) Which of these two q

7条回答
  •  感动是毒
    2020-12-06 10:50

    Nobody mentioned IDENT_CURRENT('Table1') - blows them all away - of course it only works on identity columns, but that was the question...

提交回复
热议问题