Sql 游标,是一个很好用的东东,下面给出它的一个示例:
declare my_cursor1
cursor for
select nContentId,dtEditTime
from content
where datepart(
month,dtEditTime)
='9' and datepart(
day,dtEditTime)
='26'
open my_cursor1
declare @date sysname
declare @nID sysname
declare @tempDate datetime
fetch next from my_cursor1
into @nID,
@date
while(
@@fetch_status = 0)
begin
set @tempDate = dateadd(
day,
87,
@date)
--print @tempDate
update Content
set dtEditTime
=@tempDate where nContentId
= @nID
fetch next from my_cursor1
into @nID,
@date
end
close my_cursor1
deallocate my_cursor1