transact-sql数组(转)

文章出处:http://dev.csdn.net/article/81737.shtm
需要在sql server里用到数组这样的数据结构.而transact-sql没有内建数组,听说可以用字符串配合临时表来实现,自己试了,解决方法如下 :
create proc [dbo].[CreateArray]
@string varchar(1024)
as
create table #array (id int identity,value varchar(32))
set @string='insert #array select '''+replace(@string,',','''as str union all select ''')+''''
exec(@string)
select * from #array

go

执行如下 :

exec CreateArray 'CChess,Dig,GoBang,LandLord,Majiang'


posted @ 2007-11-30 00:16  pensir  阅读(619)  评论(0编辑  收藏  举报