标签:
declare @IDList as varchar(max) declare @ID as int declare @i as int set @IDList=‘‘ select @IDList=@IDList + cast(id as varchar(50)) + ‘,‘ from table while CharIndex(‘,‘,@IDList)<>0 Begin set @ID = SubString(@IDList,1,CharIndex(‘,‘,@IDList)-1) print(@ID) set @IDList = Replace(‘,‘+@IDList,‘,‘+Cast(@ID as nvarchar(50))+‘,‘,‘‘) End
标签:
原文地址:http://www.cnblogs.com/timy/p/4867468.html