多行合并成一行. declare @tab table (id int )declare @i intdeclare @str varchar(300)select @i = 0 ,@str = \'[\'while @i < 20 begin insert into @tab select @i select @i = @i + 1 endselect @str = @str + cast(id as varchar) + \',\' from @tabselect @str =substring(@str,1,len(@str) -1 ) + \']\'select @str 参见:一行折分成多行: http://www.cnblogs.com/newsea/archive/2006/10/19/533285.html 相关文章: 2021-05-15 2022-12-23 2021-12-13 2022-12-23 2021-08-03 2022-12-23 2021-12-17