Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dewacorp.alliances
452 Posts |
Posted - 2007-01-06 : 19:23:50
|
Hi allI need some guidance how to the following query. Basically, I got table as follow:Customers:CustomerID,CustomerNameCustomerGenresCustomerIDGenreIDGenres:GenreIDGenreNameI want to display a list that as follow:"John Doe", "Pop, "Rock", Classical""Val", "Rock"Thanks |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-01-06 : 21:52:33
|
create function csvtbl(@CustomerID as int)returns varchar(8000)ASbegindeclare @csv varchar(8000)select @csv = coalesce(@csv+',','') + GenreNamefrom Genres gjoin CustomerGenres ggon g.GenreID = gg.GenreIDwhere CustomerID = @CustomerIDreturn @csvendgoselect CustomerName, dbo.csvtbl(CustomerID)from Customers==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|