For SQL Server 2005 and higher ...
You can make INSERT and SELECT in one call using the OUTPUT clause ...
INSERT MyTable (col1, col2, ..., coln) OUTPUT INSERTED.keycol, INSERTED.col1, INSERTED.col2, ..., INSERTED.coln VALUES (val1, val2, ..., valn)
Otherwise, you only use SCOPE_IDENTITY ()
source share