
复制Create table Tab([Col1] int,同列
[Col2] nvarchar(1)) Insert Tab select 1,Na union all select 1,Nb union all select 1,Nc union all select 2,Nd union all select 2,Ne union all select 3,Nf Go create function F_Str(@Col1 int) returns nvarchar(100) as begin declare @S nvarchar(100) select @S=isnull(@S,)+Col2 from Tab where Col1=@Col1 return @S end go Select distinct Col1,Col2=dbo.F_Str(Col1) from Tab go ================================ 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.