create table tb(no int,b varchar(10))

insert into tb select 1,'2'
union all select 1,'3'
union all select 1,'4'
union all select 2,'5'
union all select 2,'6'
union all select 2,'7'
go

create function dbo.fc_str(@no varchar(100))
returns varchar(100)
as
begin
 declare @sql varchar(1000)
 set @sql=''
 select @sql=@sql+' '+cast(b as varchar(100)) from tb where no=@no
 return stuff(@sql,1,1,'')
end
go

select no,dbo.fc_str(no) as b from tb group by no
drop table tb
                                                                                                althor :miss wang reshipment

posted on 2006-12-31 10:47  维德成员  阅读(168)  评论(1编辑  收藏  举报