Get Record id when doing insert
USE [staging]
GO
/****** Object: StoredProcedure [dbo].[ngHistoryAdd] Script Date: 2/16/2017 10:04:43 AM ******/
DROP PROCEDURE [dbo].[ngHistoryAdd]
GO
/****** Object: StoredProcedure [dbo].[ngHistoryAdd] Script Date: 2/16/2017 10:04:43 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
/****** Object: Stored Procedure dbo.ngHistoryAdd Script Date: 28/01/2005 12:46:42 ******/
CREATE PROCEDURE [dbo].[ngHistoryAdd]
(
@ExternalID int,
@CustomerID int,
@ParticipantID int,
@ClassID int,
@CentreID int,
@CompanyID int,
@BookingDeliveryID int,
@ActionID int,
@HistoryTimestamp datetime,
@Info text,
@UserID int,
@HistoryID int output
)
AS
SET NOCOUNT OFF;
INSERT INTO ngHistory(ExternalID, CustomerID, ParticipantID,ClassID,CentreID,CompanyID,BookingDeliveryID,ActionID,HistoryTimeStamp, Info,UserID) VALUES (@ExternalID, @CustomerID, @ParticipantID,@ClassID,@CentreID,@CompanyID,@BookingDeliveryID,@ActionID,@HistoryTimestamp, @Info,@UserID)
Set @HistoryID = SCOPE_IDENTITY() //return the primary key of the record inserted
SELECT @HistoryID
GO