日期:2014-05-18 浏览次数:20499 次
create table Product ( productID varchar(10), name varchar(100) ) --测试数据 insert into Product select 'product1','aaa' union all select 'product2','bbb' union all select 'product3','ccc' union all select 'product4','ddd' CREATE PROC ProductList @provarchar nvarchar(max) OUTPUT -- 要输出的参数 AS BEGIN select @provarchar=isnull(@provarchar+',' , '')+ productID from Product END DECLARE @ProductList nvarchar(max) EXEC ProductList @ProductList OUTPUT select @ProductList --结果 --product1,product2,product3,product4