SQL - Inserting a row and returning primary key

前端 未结 8 1185
南笙
南笙 2020-12-01 18:07

I have a little witty problem. Say, I inserted a row with some data in a table where a primary key is present. How would one \"SELECT\" the primary key of the row one just i

8条回答
  •  广开言路
    2020-12-01 18:23

    For MS SQL Server:

    SCOPE_IDENTITY() will return you the last generated identity value within your current scope:

    SELECT SCOPE_IDENTITY() AS NewID
    

提交回复
热议问题