Question : SQL Query - Combine 2 or more lines together

Hello experts,

I created a query to pull items off a sql server 2005 database.  It is pulling what I need, but is it possible to group 2 or more line items together?  The only issue with grouping is that 2 record would be the same except for a field.  I want to combine those 2 items as if it's one.

Example:
ID         Description              Code            Date Due
1234    This is a test.            ABC              8/25/2010
1234     This is a test.           EFT               8/25/2010

Both of the above combined to look like:

ID         Description              Code                     Date Due
1234    This is a test.            ABC, EFT              8/25/2010

Is it possible?

Answer : SQL Query - Combine 2 or more lines together

check the below:
1:
2:
3:
4:
5:
6:
select 	distinct
	t1.ID, 
	t1.Description,
	stuff((select ',' + Code from yourtable where ID = t1.ID for xml path('')), 1,1,'') as Codes,
	t1.[Date Due]
from yourtable as t1
Random Solutions  
 
programming4us programming4us