I’m trying to figure out if I can write an automatic script/function/event in SQL Server to deal with the following:
“When new row added to Table X, copy Table Y rows to Table Z”
Does SQL Server handle this sort of functionality, or do I have to do this in an outside program like C#?
Thanks a lot – kcross
EDIT: A bit more detail on the problem..
Table X = a normal database table, stored rows of, lets say, user information.
Table Y = a database table of fixed rows, that stores live data (like GPS coordinates of plane)
Table Z = used to store historical information on whenever a new user is added to Table X. For example, say a new row is added to Table X. The problem requires the live data at the time that the new row is added to Table X. This table will store that data, and the corresponding new row and data in this table is linked by a identifying number.
So when new row is added to Table X, create a script that automatically copies that live data for Y into a new row Table Z [and also store the corresponding identifier so that Table X’s new row can be matched to Table Z’s corresponding row(s)]
You can use a trigger for this.
I’d give more specifics, but you didn’t really provide any in the question, so…