首页 > 数据库技术 > 详细

sql 列集合转换成逗号分隔的字符类型

时间:2015-11-09 12:45:23      阅读:276      评论:0      收藏:0      [点我收藏+]
CREATE function [dbo].[getGroupPath](@groupId int)
returns nvarchar(2000)
as
begin 
declare @path nvarchar(2000)=‘/‘;
with cr as
(
select * from FAQGroup where Id=@groupId
union all
select b.* from cr a join FAQGroup b on a.ParentId=b.id 
)   
select @path=@path+cast(ID as nvarchar) +‘/‘     from cr order by id  
 
return left(@path,len(@path))  

  

sql 列集合转换成逗号分隔的字符类型

原文:http://www.cnblogs.com/zjflove/p/4949469.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!