Safest way to get last record ID from a table

后端 未结 8 1169
遇见更好的自我
遇见更好的自我 2020-12-03 09:53

In SQL Server 2008 and higher what is the best/safest/most correct way

  1. to retrieve the ID (based on autoincrementing primary key) out of the database table?
8条回答
  •  孤街浪徒
    2020-12-03 10:40

    One more way -

    select * from  where  id=(select max(id) from 
    )

    Also you can check on this link -

    http://msdn.microsoft.com/en-us/library/ms175098.aspx

    提交回复
    热议问题