create table t
(tableid nchar(30))
insert t
select 'T1' union all
select 'T2' union all
select 'T3' union all
select 'T4' union all
select 'T5' union all
select 'T6'
go
create function f_he()
returns @t table(col varchar(50))
as
begin
declare @sql varchar(50)
set @sql=''
select @sql=@sql+ltrim(rtrim(tableid)) from t
insert @t values (@sql)
return
end
go
select * from t
select * from dbo.f_he()
drop function f_he
drop table t
col
--------------------------------------------------
T1T2T3T4T5T6