方法一:
SELECT STUFF((SELECT ',' + CONVERT(VARCHAR(10),id) from product for xml path('')),1,1,'')
方法二:
SELECT @output = @output + ',' + CAST(id AS VARCHAR) from product
方法一经过测试100w数据通过
方法二大概10万时间久比较长
SELECT STUFF((SELECT ',' + CONVERT(VARCHAR(10),id) from product for xml path('')),1,1,'')
SELECT @output = @output + ',' + CAST(id AS VARCHAR) from product