ALTER TRIGGER [dbo].[TR_O_SALESMAN_INS]
ON [dbo].[O_SALESMAN]
AFTER INSERT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- inte
My scenerio is, (Table Names: Stock, StockLog)
I am inserting bulk rows inside Stock table through a Stored Procedure and want to also have all these rows inside StockLog table
first i was doing same as you (by variables) inside my insert trigger for Stock table but getting error because by using
DECLARE @StocklId bigint
SET @StocklId = (SELECT StocklId FROM inserted)
i was having multiple values by (SELECT StocklId FROM inserted) as i was inserting multiple rows, then i remove all variables, and now i am doing this
INSERT INTO StockLog(StocklId,PharmacyId,TransactionDetailId,ProductId,TotalQty,ReservedQty,AvailableQty,strUserName,strTerminalName,strVer)
SELECT StocklId, PharmacyId, TransactionDetailId, ProductId, TotalQty, 0, AvailableQty,strUserName, strTerminalName, strVer FROM inserted
and now everything is fine