This may be a trivial question, but I will ask it anyway: can updates in three or four tables in one database trigger updates to one or two tables in another database (in MS SQL 2005?) I am happy to create any amount of T-SQL necessary, and I also have VS 2008 with C# ability but have never written a trigger like that before.
Essentially, I had the ‘GetProducts()’ of the data repository call my stored procedure anytime any data was loaded with what scope they needed, and I physically changed the ‘cached’ data. Everything in life was good.
Now, they don’t want the data update as part of the repository at all. They feel that it is external to the project and should be handled without interaction.
Anyone have any suggestions on what to pursue? Links to ideas already out there would be fantastic.
A trigger only kicks off when one table is updated,inserted or deleted. If you havea specific order the tables must be inserted, you could put the trigger on the last one.
Alternatively you could write the trigger to examine the other tables as well to ensure all have records. Or you could write one trigger for each table. Or if real time updates are not required, you could have a job that runs periodically to handle the changes needed. Not knowing exactly what you want to do, it is hard to say what is the best way to handle your particular situation. Whatever you do with the triggers, remember triggers operate on sets of data not one row at a time. They should always be written to handle multiple row inserts,updates or deletes or sooner or later your trigger will cause data integrity problems. Do not do this in a cursor unless you like having your production tables locked for hours at a time when someone needs to put in 3,000,000 new records for a new client.