MSSQL 列拼接

SELECT  *
FROM    ( SELECT DISTINCT
                    ZoneEPacket
          FROM      Logistics_Country
        ) A
        OUTER APPLY ( SELECT    STUFF(( SELECT  ';' + ENName
                                        FROM    dbo.Logistics_Country c
                                        WHERE   c.ZoneEPacket = A.ZoneEPacket
                                      FOR
                                        XML PATH('')
                                      ), 1, 1, '') AS name
                    ) AS n;
                    

 

posted @ 2018-03-07 16:15  烽火情怀  阅读(172)  评论(0编辑  收藏  举报