tsql - SQL-Copy a record with its related child records -


I want to copy the line to SQL, which has 2 other records in the child's hair. If I duplicate the master record then I want to duplicate them all. For example, if I say I want to copy the master record with ID 15 with a new record. I want all your records to be duplicated with the new Master Records ID. It can use loops and conditions through TOSQL. But I just want to know that there are better alternatives.

Thank you.

"itemprop =" text ">

The best option is to get your master table that is the children of the same old line and insert them into the baby table. Is to use a combined trigger on

I have run on a lot of rags, but something like this:.

  To create tr_master trigger on master, select the childtable (masterid, childvalue) insert inserted.id as inserted probe, oldchildren.childvalue inserted on oldchildren.masterid = inserted .copiedfromid childtable oldchildren Join)  

, is triggered by, it is not "address" which records the copied gurus from the current recorded record (s) The key must be tracked in a table in the master table (which I labeled "copiedfromid" here In)

"insert" is a special table that is available within all of the rows that are being inserted into your master table in that transaction I used for "insert after" Instead of plain old "for inclusion" because I am thinking that implementing referential integrity with my child's foreign key master table, I think You only have to speed up this action after actually joining.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -