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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Concatenate partial data from different records

Author  Topic 

ceday
Starting Member

4 Posts

Posted - 2008-07-01 : 11:40:59
I need to group information by an "ID" and concatenate the "description" of the records. Can anyone help?

Example table:

DECLARE @Sample TABLE (ID INT, Description VARCHAR(100))

INSERT @Sample
SELECT 1, 'Data Record1 3/19/06 N ABC'
SELECT 1, 'Data Record 2 3/19/06 N ABC'
SELECT 2, 'Something from ID 2 12/01/07 B'
SELECT 2, 'Something else from ID 2 12/01/07 B'

Desired results:

1 'Data Record1 Record 2 3/19/06 N ABC'
2 'Something Something else from ID 2 12/01/07 B'

ceday
Starting Member

4 Posts

Posted - 2008-07-01 : 11:51:07
Sorry - the result should be:
1 'Data Record1 Data Record 2 3/19/06 N ABC'
2 'Something Something else from ID 2 12/01/07 B'

Thanks for any help you can give.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-01 : 12:17:34
Here's a start
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=97001&SearchTerms=row,concatenation

Jim
Go to Top of Page
   

- Advertisement -