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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need Query

Author  Topic 

pradeep_iete
Yak Posting Veteran

84 Posts

Posted - 2008-11-08 : 00:47:44
Hello Guys ,

I have a view like this

celebID-------- subcategoryID

34 -------- 2
34----------3
12---------4
15---------9
I want my result shud be
RESULT SET :
celebID----------subcategoryID
34 ---------------2,3
12-----------------4
15----------------9

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-08 : 01:01:17
[code]SELECT DISTINCT celebID,
STUFF((SELECT ',' + CAST (subcategoryID as varchar(4)) FROM YourView WHERE celebID=v.celebID FOR XML PATH('')),1,1,'') AS subcategoryID
FROM YourView v
[/code]
Go to Top of Page
   

- Advertisement -