字符处理(1)

use test
create table t_example(id int identity(1,1) not null,
meetingid varchar(10),Joiner varchar(10))


Insert t_example select '1000','李梅'

union all select '1000','王俊'
union all select '1000','张风'

union all select '1001','王浩'

union all select '1001','刘涛'

Create function fn_merge(@id int)
returns varchar(8000)
as
begin
declare   @r   varchar(8000)
set @r=''
select @r=@r+','+Joiner from t_example where meetingid=@id
return stuff(@r,1,1,'')
end

go
select   meetingid,   dbo.fn_Merge(meetingid)   as   joiner   from t_example group   by   meetingid
   
go

drop   function   fn_Merge


drop   table  t_example

 

历史评论

暂无保留的历史评论。

评论为旧站历史记录,本站不再接受新评论。