--------------------------------------------------
Function:把id串联起来
Author:  Robot.H
---------------------------------------------------*/
SET NOCOUNT ON 
--prepare data
DECLARE @t TABLE(id int )
INSERT INTO @t select 1
UNION ALL      select 2
UNION ALL      select 3
UNION ALL      select 4
--method1
DECLARE @str as varchar(200)
select @str=ISNULL(@str+',','')+CAST(id AS VARCHAR(200)) from @t
PRINT @str
--method2

select @str=
(
select cast(id as varchar(200))+',' 
from @t 
for xml path('')
)
print 

相关文章:

  • 2021-05-30
  • 2021-09-25
  • 2022-12-23
  • 2021-09-12
  • 2021-06-18
  • 2022-12-23
  • 2022-03-08
  • 2021-08-27
猜你喜欢
  • 2022-02-21
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2021-07-11
  • 2022-12-23
相关资源
相似解决方案