How to add two text row on same column in T-SQL

How can I add two text row on same column, or any alternative aggregate function which can apply sum() on text columns.

id       Name       
1          A        
1          B        
2          C        

group by id

  • Sql getting two rows from second table in one statement
  • How do you select the highest of a count()?
  • Query to list SQL Server stored procedures along with lines of code for each procedure
  • Either/Or Relationship in Database design improvement
  • Generic Data Access functions
  • SQL Server - For Insert trigger
  • result like this.

    id  Names
    1   A,B
    2   C

    One Solution collect form web for “How to add two text row on same column in T-SQL”

    Try this:

    declare @t table(id int, name varchar(50))
    insert @t values(1, 'A')
    insert @t values(1, 'B')
    insert @t values(2, 'C')
            select ',' + [name] 
            from @t t1 
            where = 
            for xml path(''), type 
        ).value('.', 'varchar(max)'), 1, 1, '') [Names] 
    from @t t 
    group by 


    id          Names
    ----------- --------------
    1           A,B
    2           C
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.