34,591
社区成员
发帖
与我相关
我的任务
分享
create function ws(@file2 varchar(10))
returns varchar(8000)
as
begin
declare @ret varchar(8000)
select @ret = isnull(@ret+',','')+file1 from tb where file2 = @file2
return @ret
end
go
select distinct file1=dbo.ws(file2),file2 into #t from tb
delete tb
insert into tb (file1,file2 )
select file1,file2 from #t
--难道不是这样?
SQL code
create function ws(@file2 varchar(10))
returns varchar(8000)
as
begin
declare @ret varchar(8000)
select @ret = isnull(@ret+',','')+file1 from tb where file2 = @file2
return @ret
end
go
select distinct file1=dbo.ws(file2),file2 from tb