synovacorp
asked on
How do Insert records in TableB based on a Batch insert of Records from TableA on a Trigger?
I'm somewhat new to the use of Triggers in MS SQL. My initial creation only gives me 1 new record in the second table(SMI_STATUS) , regardless of the number of records inserted into
the firts table that fires the trigger (TicketPoolHist).
I've looked at several examples on the web, realizing that I need to do a "set" approach, but I can't seem to put it together. Any suggestions?
Brian
Currrent Trigger , which only works on the last record in the Inserted table is shown below.
the firts table that fires the trigger (TicketPoolHist).
I've looked at several examples on the web, realizing that I need to do a "set" approach, but I can't seem to put it together. Any suggestions?
Brian
Currrent Trigger , which only works on the last record in the Inserted table is shown below.
CREATE TRIGGER [STLog1] ON [dbo].[TicketPoolHist]
AFTER INSERT,UPDATE
AS
declare @Datestamp as datetime,
@TableName as Char(20),
@TableUID as Integer,
@Status as Char(1)
Select
@TableUID = Identity_Column
From Inserted
INSERT INTO smi_Status(DateStamp,TABLENAME,TABLEUID,STATUS) VALUES (Current_TimeStamp,'TicketPoolHist',@TableUID,1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many Thanks.
Brian