Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want create trigger for two tables my tables are subcomment and subcommenthistory

subcomment history is duplicate table of subcomment table
my requirement is
when i insert the data into subcomment table then subcomment table is update with
new record and insert old records into subcommenthistory table
Posted

1 solution

You didn't mention the exact problem, so a brief answer. You would need to create a trigger which uses the deleted table to query the old values.

So something like
SQL
CREATE TRIGGER ABC ON subcomment
AFTER UPDATE, DELETE 
AS
BEGIN
   INSERT INTO subcommenthistory
   SELECT ...
   FROM DELETED;
END;

For more information:
- http://msdn.microsoft.com/en-us/library/ms189799.aspx[^]
- http://msdn.microsoft.com/en-us/library/ms191300.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900