Is this select possible in sql?
Consider a table,
Id columnA
1  a
2  b
3  c
Select ColumnA from table gives the result as below,
columnA
   a
   b
   c
Is it possible to get
ColumnA
a,b,c
开发者_StackOverflow中文版One way is the XML PATH trick
SELECT
    SUBSTRING(
    (
    SELECT
        ',' + columnA
    FROM
        myTable
    FOR XML PATH ('')
    )
     , 2, 7999)
FROM
     foo
heres an article describing how to do it with a stored procedure which internally uses a loop to do the concatenation.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论