Trigger updating another table
Our example will have two tables: employee table and employee_history table.We will create these tables and populate them with some data.I have table1 with a year column and if the application updates that year column I need to update table 2 with the year the same year.ALTER TRIGGER [dbo].[trig_Update Annual Year] ON [dbo].[table1] AFTER UPDATE AS if (UPDATE (int Annual Year)) BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements.I had a situation recently where we were changing an internal process that meant we would no longer be updating the data in a specific table because those column where moving to another table.
Specializing in big data deployments using My SQL / No SQL Solutions.You can download the AFTER DELETE Trigger script used here so that you can run this script on your local SQL Server, while following the problem below.We want to keep track of records deleted from employee table into employee_history table.SET NOCOUNT ON; -- Insert statements for trigger here Update table2 set Annual Year = int Annual Year where table2. SQL Server initiates an AFTER DELETE trigger whenever a delete statement event occurs.So give us a call and come enjoy beautiful Truman Lake. The crappie are coming in to the banks and we are seeing lots of really nice crappie. These cabins won't last long so give us a call quick! We have had a lot of spoonbill fishermen/women the past few weeks. We have seen some really nice crappie this past week; not to mention some good catfish.Some of them have done well and others not as good as they hoped. My apologies for not posting reports during the past two months. On the bright side, one of our employees said he caught 31 fish last night. Jim caught a 2.9 lb 17" crappie last Friday and Keith caught a 16" crappie Monday! Check out our Facebook page to see the latest pictures. The weather has warmed up and the evenings are mild.Bill explores the basic syntax, using SQL statements to create, insert, update, and delete data from your tables.He also covers creating a new database from scratch, as well as data types, transactions, subselects, views, and stored routines.So below we are using an Update statement with Inner Joins.Another cool feature I had forgotten about is the Inserted and Deleted tables.