declare @t table(id int,num int)
insert @t
select 1,2 union all
select 2,4 union all
select 3,6
--select * from @t

----查询
declare @idList varchar(1000),@numList varchar(1000)
set @idList = ''
set @numList = ''
select 
@idList = case @idList when '' then '' else @idList + ',' end + rtrim(id),
@numList = case @numList when '' then '' else @numList + ',' end + rtrim(num)
from @t

select @idList as id,@numList as num

/*结果
id      num
------------------
1,2,3   2,4,6
*/

 

相关文章:

  • 2021-10-07
  • 2021-07-18
  • 2021-06-15
  • 2022-12-23
  • 2021-12-26
  • 2022-01-29
  • 2021-08-11
猜你喜欢
  • 2022-12-23
  • 2021-10-12
  • 2022-01-18
  • 2021-10-31
  • 2021-07-09
  • 2021-09-21
  • 2021-08-21
相关资源
相似解决方案