Declare @icol1 varchar(30)
Declare iCursor Cursor For
Select col1 from Table where ..
Open iCursor
Fetch next from iCursor into @iCol1
While @@Fetch_Status=0
Begin
--你需要执行的SQL语句
Fetch Next from iCursor into @iCol1
End
Close iCursor
Deallocate iCursor
declare @tables table ( tid int identity(1,1) ,today varchar(50) , today varchar(50) )
select *
into @table
from date
select @tid = 1, @tmax = max(tid), @err = 0 from @tables
循环
while (@tid <= @tmax) and ( @err = 0)
begin
....
end