How to make a stored procedure return the last inserted id
- by Luke101
Here I have a stored procedure that inserts a row but how do you make it return the last inserted id without making another query
CREATE PROCEDURE [dbo].[spInsertCriteriaItem]
@GroupID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
insert into CriteriaItem (CriteriaGroupID) VALUES(@GroupID)
--I don't want to make another query here
END
Is it possible to do this