Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Trigger to update field from rows

$
0
0
I'm tracking sales reps and the companies they represent.
I have 2 tables.
A header table that has the SalesRep (a key field) the name, phone, address, etc.

A line file that will have the sales rep multiple times, each line having a vendor they represent.

SalesRepHeader table:
SalesRep name phone VendorList
Bob Bob_Smith 111-222-3333
John John_Young 123-456-56789
Mary Mary_Kerns 567-876-98765

SalesRepLines table:
SalesRep Vendor
Bob Samsung
Bob Kenwood
Bob JVC
John APPLE
John HP

Whenever the SalesRepLine file is added to or updated I want the header file field VendorList to be updated with a concat of the vendors for this sales rep so the SalesRepHeader file would look like this.

SalesRep name phone VendorList
Bob Bob_Smith 111-222-3333 Samsung, Kenwood, JVC
John John_Young 123-456-56789 Apple, HP

I need the update to be automatic so I'm thinking a trigger would be best.

Thanks for any help
Craig

Viewing all articles
Browse latest Browse all 13329

Trending Articles