|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 5:32 AM
Points: 124,
Visits: 324
|
|
Dear, I have an application running on my system. There is a certain module that if I click on 'Save' button, it inserts a row on Header & Detail tables. Now I want to write a single trigger on Header & Detail tables which will insert a row into 'Test' table.
How can I do this? Please help me.
Regards, Akbar
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Yesterday @ 1:38 AM
Points: 53,
Visits: 150
|
|
if you want to insert the data from the two tables (header and detail) to test table you can do something like this...
1. get the inserted value in dbo.inserted 2. join dbo.inserted and Header Table.
sample code below
CREATE TRIGGER Detail_Insert ON detail FOR INSERT AS
insert into Detail_table select I.id, * from dbo.inserted I inner join header H on I.id = H.Id
This code will work. Just make some neccessary adjustment as to what fields to you want
|
|
|
|