SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Combining values in one field of crosstab results
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

Sara Karasik
Starting Member

10 Posts

Posted - 01/29/2008 :  15:24:24  Show Profile  Reply with Quote
It CAN be done in SQL 2005.

Not the simplest coding, but not the most difficult, either.
You can get your list into a single string by using FOR XML and cross apply.

Here's an example. (assume a table SupplierProducts with two fields, Supplier and Product. Each supplier can have one or more products.


select distinct supplier, left(o.list, len(o.list) -1)
from SupplierProducts c
cross apply
(
select Products + ', ' AS [text()] from code c2
where c.supplier = c2.supplier
for xml path('')
) o(list)


Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000