njfuller (2/6/2013)
In this case, the applications group is inserting only one tb1 record in a transaction.1 or more tb2 records could be inserted.
I would like the identity value from the tb1 insert returned so I can use it to update on all the tb2 records.
(It would be nice if the appl would do this for me, but not in their scope) :).
i know you abstracted everything out (tbl1/tbl2) to simplify, but it doesn't look right.
if i insert into tbl1, you KNOW there is already a matching row in tbl2? or should that be an insert into tbl2 when tbl1 gets inserted?
create TRIGGER [dbo].[trg_tb1_Insert]
ON [dbo].[tb_tb1]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
UPDATE dbo.tb2
SET tb2_id = Inserted.ColumnWithIdentity
FROM Inserted
WHERE Inserted.tb1_id = dbo.tb2.tb1_id
END
Lowell