SQL Server – Return value after INSERT

No need for a separate SELECT…

INSERT INTO table (name)
OUTPUT Inserted.ID
VALUES('bob');

This works for non-IDENTITY columns (such as GUIDs) too

Leave a Comment