What is the best way to get IDENTITY of inserted row?
IDENTITY
I know about @@IDENTITY and IDENT_CURRENT and SCOPE_IDENTITY
@@IDENTITY
IDENT_CURRENT
SCOPE_IDENTITY
Add
SELECT CAST(scope_identity() AS int);
to the end of your insert sql statement, then
NewId = command.ExecuteScalar()
will retrieve it.