|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Make view or stored procedure to Append many fields to single field view from 1 to many tablewith the 'many' table containing authors. I need to come up with a view (stored procedure?) that will combine any number of authors into a single view field that can be queried against. I guess a stored procedure that looks like a view for reporting. The result would look something like: ITEM, ALL_AUTHOR_NAMES to the user, a flat view of item and it's authors. I figure the procedure needs to loop on each ITEM record, Select all authors linked to it then loop through the recordset and append each author name to a display field. Parent Table ITEMS Fields: ITEM, Description, AuthorID Child Table: AUTHORS Fields: AuthorID, AuthorName Thanks for any help Kevin See if this solutions (thanks to Anith Sen) work for you:
http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/2d85bf366dd9e73e BTW, table [authors] is the parent in this relation. AMB Show quote "Kevin R" wrote: > Is it possible to do the following in SQL? I have a '1- many' table link > with the 'many' table containing authors. I need to come up with a view > (stored procedure?) that will combine any number of authors into a single > view field that can be queried against. I guess a stored procedure that > looks like a view for reporting. The result would look something like: > ITEM, ALL_AUTHOR_NAMES to the user, a flat view of item and it's authors. > > I figure the procedure needs to loop on each ITEM record, Select all authors > linked to it then loop through the recordset and append each author name to > a display field. > > Parent Table ITEMS > Fields: ITEM, Description, AuthorID > > Child Table: AUTHORS > Fields: AuthorID, AuthorName > > Thanks for any help > > Kevin > > > > I'll give this a shot.
Thanks! Show quote "Alejandro Mesa" <AlejandroM***@discussions.microsoft.com> wrote in message news:C125B94E-2B50-4B49-BC33-E001AE703D15@microsoft.com... > See if this solutions (thanks to Anith Sen) work for you: > > http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/2d85bf366dd9e73e > > BTW, table [authors] is the parent in this relation. > > > AMB > > "Kevin R" wrote: > >> Is it possible to do the following in SQL? I have a '1- many' table link >> with the 'many' table containing authors. I need to come up with a view >> (stored procedure?) that will combine any number of authors into a single >> view field that can be queried against. I guess a stored procedure that >> looks like a view for reporting. The result would look something like: >> ITEM, ALL_AUTHOR_NAMES to the user, a flat view of item and it's authors. >> >> I figure the procedure needs to loop on each ITEM record, Select all >> authors >> linked to it then loop through the recordset and append each author name >> to >> a display field. >> >> Parent Table ITEMS >> Fields: ITEM, Description, AuthorID >> >> Child Table: AUTHORS >> Fields: AuthorID, AuthorName >> >> Thanks for any help >> >> Kevin >> >> >> >> |
|||||||||||||||||||||||