Link to home
Start Free TrialLog in
Avatar of Lev Seltzer
Lev SeltzerFlag for Israel

asked on

Combine child records into flat table

I have a parent-child relationship between two tables.  I need to create a new view for exporting for use in a spreadsheet or a word processor. This view needs to have all the related child records combined into one field and included in the parent record of this new, flattened table.

More specifically, the tables are books (parent) and authors (child).  We can have multiple authors for each book.  I want to end up with a table/view/query listing book titles in one field, and ALL author names in another field. The author names should be separated by a comma and space (if we can't get rid of the last comma, that isn't such a problem).

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lev Seltzer

ASKER

This looks good.  Can you please tell me, though, where do I enter the function? (I haven't used functions in MSSQL before). I work with both MS Access & enterprise manager.

Thanks.
navigate to user-defined functions in EM.  Create New Function.  Copy/Paste the code above in and save it.  Feel free to change names/datatypes as appropriate.
I entered your code (customizing for my actual data structures) and it worked perfectly.  Thank you very much for your fast and accurate answer!