Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
my target is to copy the data to another table if the mt_processed is updated ! this trigger is working but: 1-i need to improve it using another method 2- i need to add that if the mt_processed was updated to 10 i need to insert the data to a certain table and if it was updated to 1 i need to insert the data to a different table ..

i have the following trigger :

SQL
ALTER trigger afterUpdateProcessed
on MT_PROCESS
for update as begin declare var select data=var insert var

i appreciate your help :)
Posted
Comments
ZurdoDev 6-Sep-13 7:39am    
Where are you stuck?

1 solution

Hi,

Yes Trigger will surely help you in this scenario, you have to define trigger on your table and then you need to use Inserted and delete logical Table to view which data is updated or you can get both type of values old and new from this tables and from that value you can decide your operation you want to insert in which table , hope this will help you.

You can refer this article

http://www.dotnet-tricks.com/Tutorial/sqlserver/7OT8250912-Inserted,-Deleted-Logical-table-in-SQL-Server.html



http://social.msdn.microsoft.com/Forums/sqlserver/en-US/0ccec191-d161-4054-a81c-28dba1bcde85/audit-trigger-using-inserted-and-deleted-tables

Regards,

Mubin
 
Share this answer
 
Comments
Joezer BH 10-Sep-13 2:59am    
5ed!

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