Retrieving the value of RETURN @@IDENTITY in C#

后端 未结 5 1901
说谎
说谎 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:16

    Sounds to me like you want to execute with a scalar value

    SqlCommand.ExecuteScalar()
    

    as others have mentioned I think using SCOPE_IDENTITY() is more secure than the @@IDENTITY variable

提交回复
热议问题