Please note that the same question already has been asked in http://stackoverflow.com/questions/111341/combine-multiple-results-in-a-subquery-into-a-single-comma-separated-value, but the solution involves creating a function. I am asking if there is a way to solve this without having to create a function or a stored procedure.
I have two tables, Book and Tag, and books are tagged using the association table BookTag. I want to create a report that contains a list of books, and for each book a list of the book's tags. Tag IDs will suffice, tag names are not necessary.
Example:
Book table:
Book ID | Book Name
28 | Dracula
BookTag table:
Book ID | Tag ID
28 | 101
28 | 102
In my report, I'd like to show that book #28 has the tags 101 and 102:
Book ID | Book Name | Tags
28 | Dracula | 101, 102
Is there a way to do this in-line, without having to resort to functions or stored procedures? I am using SQL Server 2005.