Introduction
Suppose I have a table as in the following.

And you need to return all the names as a comma-separated string, as in the following.
Rahul Saxena, Sara Sinha, Priyanka Mathur, Shambhu Sharma, Manu Khanna, Ganga, Shweta, Shraddha, Akhilesh, Mayank, Rakesh, Abhishek, Saurabh
Use the following command.
SELECT SUBSTRING((
SELECT ',' + CAST(Name AS VARCHAR) FROM Employee
FOR XML PATH('')), 2,10000) AS NAME

If you want to provide a condition then.
SELECT SUBSTRING((
SELECT ',' + CAST(Name AS VARCHAR) FROM Employee WHERE Country='India'
FOR XML PATH('')), 2,10000) AS NAME

If you want to show your result group by a column, then use the following query.
SELECT DISTINCT Country,
STUFF(
(
SELECT ',' + CAST(Name AS VARCHAR)
FROM Employee AS t2
WHERE t2.Country = t.Country
FOR XML PATH('')
), 1, 1, '') AS id_list
FROM Employee AS t


Rahul Kumar SaxenaPosted Mar 31, 2015, 1:02 PM
Thanks Tom Mohan...
Rahul Kumar SaxenaPosted Mar 31, 2015, 1:02 PM
Thanks Karthik Muthu Karuppan..
Rahul Kumar SaxenaPosted Mar 31, 2015, 1:02 PM
Thanks Santhakumar Munuswamy...
Rahul Kumar SaxenaPosted Mar 31, 2015, 1:02 PM
Thanks Gowtham Rajamanickam..
Rahul Kumar SaxenaPosted Mar 31, 2015, 1:02 PM
Thanks Khargesh Rajput..
Rahul Kumar SaxenaPosted Mar 31, 2015, 1:01 PM
Thanks Nitin Tyagi...
Tom MohanPosted Mar 31, 2015, 12:31 PM
good show
Karthik Muthu KaruppanPosted Mar 31, 2015, 10:58 AM
nice
Santhakumar MunuswamyPosted Mar 31, 2015, 6:37 AM
Thanks for nice one
Gowtham RajamanickamPosted Mar 31, 2015, 6:02 AM
good one..
Khargesh RajputPosted Mar 31, 2015, 5:57 AM
nice
NitinPosted Mar 31, 2015, 3:32 AM
Good one