要先把數值轉換成文字~才可以整併
declare @Tmp table(
DocNum int
)
insert into @Tmp
values(386)
,(352)
,(385)
select STUFF(
(
select ',' + Convert(varchar,DocNum)
from @Tmp
for xml path('')
)
,1,1,''
) as AllNumber
select AllNumber = STUFF(
(
SELECT ',' + cast([DocNum] AS VARCHAR )
FROM T
FOR XML PATH('')
),1,1,''
)
結果:
AllNumber
-----------
386,352,385