1、定义变量
Declare @i Int
2、获取单条记录
Select @i=Min([id]) From [数据库名] Where <检索条件>
3、While循环
While @i Is Not Null
Begin
<执行部份>
/*重新获取i,直到没有记录*/
Select @i=Min([id]) From [数据库名] Where <!检索条件> And [id]>@i
End
1、定义变量
Declare @i Int
2、获取单条记录
Select @i=Min([id]) From [数据库名] Where <检索条件>
3、While循环
While @i Is Not Null
Begin
<执行部份>
/*重新获取i,直到没有记录*/
Select @i=Min([id]) From [数据库名] Where <!检索条件> And [id]>@i
End