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.
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         kt 
                                        Yak Posting Veteran 
                                         
                                        
                                        88 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2015-02-03 : 15:30:17
                                            
  | 
                                             
                                            
                                            | Hi,Result # 1 is what is currently showing. I would like my query returns the results like # 2 .  Please tell me what have wrong from the query below? - Thanksselect failedID,stuff((select ','+b.sName from [dbo].[SCName] b  where a.Id_int = b.id_int for xml path('')),1,1,'') as 'name'from [dbo].[Reason] aFailedID   name1			AA2			BB3			CC4			DD4			EE4			FFFailedID   name1			AA2			BB3			CC4			DD,EE,FF | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     gbritton 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2780 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-03 : 15:42:22
                                          
  | 
                                         
                                        
                                          | try adding "group by failedid"  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     kt 
                                    Yak Posting Veteran 
                                     
                                    
                                    88 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-03 : 16:50:10
                                          
  | 
                                         
                                        
                                          | did not work  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     gbritton 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2780 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-03 : 19:19:29
                                          
  | 
                                         
                                        
                                          quote: Originally posted by kt did not work
  Post your modified query along with some sample data  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |