Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

please i want to create trigger that will insert into another table the old value and new value

and how can i pass values from my C# application

can any one help for this pleaseeeee


thanks
Posted

1 solution

Try this use after trigger
SQL
CREATE TRIGGER ShowUpdate on YourTable
AFTER  UPDATE
AS
BEGIN
INSERT INTO NewDataTable
   SELECT id, name  FROM inserted

INSERT INTO OldDataTable
   SELECT id, name  FROM Deleted 
END
 
Share this answer
 
v3
Comments
leito6266 20-Aug-13 13:25pm    
thanks for your help
it's fine now
but i have another thing to do in the table which i want to insert into by trigger i have one column which i have to pass parameter from my application how can i do that by trigger
pradiprenushe 20-Aug-13 13:40pm    
Look here three tables are given. You can use normal update query to get value from application & fire update query on you table. Then this trigger happens. So you dont need input in trigger. Please clarify am i getting you correctly? or else elaborate some more info with some exammple
pradiprenushe 20-Aug-13 13:54pm    
If you still want to pass data refer this link
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/da4d8620-92b7-4354-90e8-103d820559f6/set-context-info-is-not-global

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