Create procedure prGetList
@chnList nvarchar(2000) output
as
Set @chnList=''
select @chnList = @chnList+Rtrim(ID)+',' from A
Select @chnList=Left(@chnList,Len(@chnList)-1)
go
@chnList nvarchar(2000) output
as
Set @chnList=''
select @chnList = @chnList+Rtrim(ID)+',' from A
Select @chnList=Left(@chnList,Len(@chnList)-1)
go
Create table A(ID Int)
--插入数据
Insert A Select 1
Union Select 2
Union Select 3
Union Select 4
Union Select 5
Union Select 6
Union Select 7
Union Select 8
Union Select 9
Union Select 10
GO
--建立存储过程
Create procedure prGetList
@chnList nvarchar(2000) output
as
Set @chnList=''
select @chnList = @chnList+Rtrim(ID)+',' from A
Select @chnList=Left(@chnList,Len(@chnList)-1)
go
--测试
Declare @chnList nvarchar(2000)
EXEC prGetList @chnList output
Select @chnList
GO
--删除测试环境
Drop table A
Drop procedure prGetList
GO
--结果
/*
1,2,3,4,5,6,7,8,9,10
*/
@chnList nvarchar(2000) output
as
Set @chnList=''
select @chnList = @chnList+Rtrim(ID)+',' from A
Select @chnList=Left(@chnList,Len(@chnList)-1)
我在大富翁上问了一天都没有人知道-------------------------------------
另外怎么结帖啊?????