sql 将某一列转成字符串并且去掉最后一个逗号

DECLARE @center_JZHW VARCHAR(500)
SET @center_JZHW = ( SELECT DISTINCT STUFF(
    ( SELECT ','''+ qudao+'''' FROM CreatedType WITH ( NOLOCK )
      WHERE   qtype = 'pc' ORDER BY qudao
      FOR XML PATH('')), 1,4, '') AS jzhw
    FROM   CreatedType t) 

set @center_JZHW= left(@center_JZHW,len(@center_JZHW)-1)
  select @center_JZHW
  
  

 

posted @ 2017-03-23 17:20  秋香姑娘请你不要紧张  阅读(3322)  评论(0编辑  收藏  举报