I have following trigger. On Insertion of a new row, the Stored Procedure is unable to get the parameter value of variable @ItemID
. I am trying to pass the value of ItemID Column of newly inserted Row to the stored procedure CalculateCurrentStock
ALTER TRIGGER UpdateCurrentStock
ON StockIn
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
EXEC CalculateCurrentStock (SELECT ItemID From INSERTED)
END
The error text reads
Procedure or function 'CalculateCurrentStock' expects parameter '@ItemID', which was not supplied. The statement has been terminated.
Thank you for help.
EDIT: Answer
I have altered the trigger as per Derek Kromm's and KM's suggestion
ALTER TRIGGER UpdateCurrentStock
ON StockIn
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @CSV varchar(max)
SELECT @CSV=ISNULL(@CSV+',','')+ItemID From INSERTED
EXEC CalculateCurrentStock @CSV
END
Thanks for help :)