Anonymous
Asked in
Cars &Transportation
·
2 weeks ago
How do I get the last inserted row ID in SQL?
Contents
How do I get the inserted row id in SQL Server?
4 ways to get identity IDs of inserted rows in SQL Server1INSERT INTO TableA (...) VALUES (...) SET @LASTID = @@IDENTITY.2INSERT INTO TableA (...) VALUES (...) SET @LASTID = SCOPE_IDENTITY()3SET @LASTID = IDENT_CURRENT('dbo.TableA')4DECLARE @NewIds TABLE(ID INT, ...) INSERT INTO TableA (...) OUTPUT Inserted.ID, ...4 ways to get identity IDs of inserted rows in SQL Server
How can get last identity value in SQL Server?
@@IDENTITY returns the last identity value generated for any table in the current session, across all scopes. SCOPE_IDENTITY returns the last identity value generated for any table in the current session and the current scope.
Related Questions
Relevance
-
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago
Write us your question, the answer will be received in 24 hours