Retrieving the value of RETURN @@IDENTITY in C#

后端 未结 5 1903
说谎
说谎 2021-01-20 03:22

Here\'s a very simple question. I have an SP that inserts a row into a table and at the end there\'s the statement RETURN @@IDENTITY. What I can\'t seem to find is a way to

5条回答
  •  青春惊慌失措
    2021-01-20 04:03

    One point to mention. You should really use SCOPE_IDENTITY to return the identity value after INSERT. There is potential for @@IDENTITY to return the wrong value. Especially if TRIGGERS are in use, writing value to other tables after INSERT.

    See the Books Online page for more detail.

提交回复
热议问题