I am just back in the field after 5 years and am very rustly so please be patient. I am working on sql server express and I need to capture new/updated records(only parts of them actually) from a single table in order to insert into another table. (I will be using this other table as my data source for a crystal report.) I have no test environment and will have to build and populate around 6 tables to test the trigger. Is a trigger my only option? Thank you for any input.
First, get a test environment. You can't work without one safely.
You can use triggers for this yes, but do you really need a separate table or will a query or view (not sure if you can have a view in Express) do as the source of the report instead.
If you choose to use a trigger, make sure to test multpe row inserts/updates/deletes. Triggers need to be designed to act on sets of data not one row at a time.
If you have 2005/2008, you can also use OUTPUT
as in this example -- providing you control the inserts.
Triggers are like Regular Expressions, if you have a problem and you solve it with either one, now you have 2 problems. I would just do to inserts in to the separate tables a single transaction from your client code. Mainly because side effect programming like Triggers do is just asking for problems down the road. If you accidentally insert some bad data and the triggers fire you can't undo the actions of the triggers easily. Triggers should be a solution or LAST resort. Inserts are no longer orthogonal, this leads to really hard to maintain code. There are a lot of better design decisions, like someone else mentioned Views, and Materialized Views are a better solution if your database supports them.