September 14, 2013 at 11:06 pm
I have following table
DepartmentID Employee
------------- ---------
1 John
1 Michael
2 Jenson
2 Lily
2 Lara
I want the output in following format
DepartmentID Employees
------------- ----------
1 John,Michael
2 Jenson,Lily,Lara
Please provide examples
September 15, 2013 at 1:44 pm
With the idea of "teaching a man to fish" in full swing, please see the following article.
http://www.sqlservercentral.com/articles/comma+separated+list/71700/
For future posts, please see the article at the first link in "Helpful Links" in my signature line below.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 15, 2013 at 7:25 pm
Jeff Moden (9/15/2013)
With the idea of "teaching a man to fish" in full swing, please see the following article.http://www.sqlservercentral.com/articles/comma+separated+list/71700/
For future posts, please see the article at the first link in "Helpful Links" in my signature line below.
Excellent advice Jeff! All you have to do is look at my avatar to see what it means to learn to fish correctly (as you have often taught me).
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
September 15, 2013 at 8:35 pm
dwain.c (9/15/2013)
Jeff Moden (9/15/2013)
With the idea of "teaching a man to fish" in full swing, please see the following article.http://www.sqlservercentral.com/articles/comma+separated+list/71700/
For future posts, please see the article at the first link in "Helpful Links" in my signature line below.
Excellent advice Jeff! All you have to do is look at my avatar to see what it means to learn to fish correctly (as you have often taught me).
Learning how to fish also increases the scalability of code. 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
September 16, 2013 at 8:35 am
Jeff Moden (9/15/2013)
dwain.c (9/15/2013)
Jeff Moden (9/15/2013)
With the idea of "teaching a man to fish" in full swing, please see the following article.http://www.sqlservercentral.com/articles/comma+separated+list/71700/
For future posts, please see the article at the first link in "Helpful Links" in my signature line below.
Excellent advice Jeff! All you have to do is look at my avatar to see what it means to learn to fish correctly (as you have often taught me).
Learning how to fish also increases the scalability of code. 😛
And greatly reduces hunger too. 😉
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 16, 2013 at 6:00 pm
Sean Lange (9/16/2013)
Jeff Moden (9/15/2013)
dwain.c (9/15/2013)
Jeff Moden (9/15/2013)
With the idea of "teaching a man to fish" in full swing, please see the following article.http://www.sqlservercentral.com/articles/comma+separated+list/71700/
For future posts, please see the article at the first link in "Helpful Links" in my signature line below.
Excellent advice Jeff! All you have to do is look at my avatar to see what it means to learn to fish correctly (as you have often taught me).
Learning how to fish also increases the scalability of code. 😛
And greatly reduces hunger too. 😉
I had a finny feeling you'd say that.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply