码迷,mamicode.com
首页 > 数据库 > 详细

tsql 循环id读取

时间:2015-10-10 17:09:53      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:

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

 

tsql 循环id读取

标签:

原文地址:http://www.cnblogs.com/timy/p/4867468.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!