Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make one row out of multiple rows

Status
Not open for further replies.

pdbowling

Programmer
Mar 28, 2003
267
US
Hello, everyone. I have a query I don't even know how to begin with. I suppose I could write a cursor to do it, but why do that if there is a query that will suffice.

I have a data set similar to this.

PK, FK, Text
1 1 This is some text
2 1 that spans more
3 1 than one row.
4 2 This text does
5 2 as well.

What I would like to do is roll up the text on the foreign key so I could get a result set like

FK Text
1 This is some text that spans more than one row.
2 This text does as well.


Again, writing the text out to a temp table with a cursor making a new row on foreign key will work, but I'm not tickled by the notion.

Suggestions or strokes of genius?

Thanks, All.

Patrick B
 
Take a look here: thread183-1159740

The only difference between your question and the one reference in the other thread is the presence of a comma delimiter, which should be easy enough to remove from the code.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top