I've got a SQL Server database with the the following tables:
Client (ClientID, ClientName)
SalesAgent (AgentID, AgentName)
Item (ItemID, Description)
Purchase (PurchaseID, ClientID, ItemID, Price)
PurchaseSalesAgent (PurchaseID, AgentID)
Each purchase is only ever one item to one client but there can have been multiple agents involved. I want to return the following list of columns:
ClientName, Description, Price, Agents
Where Agents is the names of all the agents involved in the purchase. Either as a comma separated list or as multiple columns with one agent in each.
I'm looking for a way that's compatible with SQL Server 2000 but I'd also be interested in if there's a better way of doing it in SQL Server 2008.