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
 How can Print Multiple row in one coloum

Author  Topic 

Ubaid
Starting Member

1 Post

Posted - 2011-12-08 : 06:41:15
hi,
i have a serious problem any body can help me!

std_id------------std_name
1 --------------- A
1 --------------- B
1 --------------- C
2 --------------- D
2 ---------------E
Now i want to print like this.

std_id ----------- std_name
1 ------------A,B,C
2 -------------D,E
Any body can help me plz and what's will be the query for this

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-08 : 06:53:51
[code]
SELECT std_id,
STUFF((SELECT ','+ STD_NAME FROM table where std_id=T.std_id ORDER BY std_name ASC FOR XML PATH('')),1,1,'') AS std_name
FROM (SELECT DISTINCT std_id FROM table)t
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -