去重,以逗号分开字符串
SELECT a.Dep from (SELECT --列名 --ROW_NUMBER() over(order by (select 1)) as id, c.value('.', 'varchar(50)') AS Dep FROM uf_ncr_jtbmqy a CROSS APPLY ( SELECT CAST('<row>' + REPLACE(CAST(Dep AS NVARCHAR(4000)) , ',', '</row><row>') + '</row>' AS XML) AS xmlcode ) C1 CROSS APPLY xmlcode.nodes('*') t ( c ) ) a GROUP BY Dep