declare m_cursor cursor scroll for
select a.CreateTime,s.CommentID from Comment s inner join Article a on s.ObjectID=a.ArticleID where ArticleID=122
for update
-- 打开游标
open m_cursor
declare @dataTimes Datetime, @CommentId int
--填充数据
fetch next from m_cursor into @dataTimes,@CommentId
--假如检索到了数据,才处理
while @@FETCH_STATUS=0
begin

update Comment set CreateTime=dateadd(MINUTE,CEILING(rand()*1200),cast(@dataTimes as datetime)) where CommentId=@CommentId
--填充下一条数据
fetch next from m_cursor into @dataTimes,@CommentId
end
-- 关闭游标
close m_cursor
--释放游标
deallocate m_cursor

相关文章:

  • 2022-12-23
  • 2021-04-29
  • 2021-09-20
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
猜你喜欢
  • 2021-06-19
  • 2022-01-22
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
相关资源
相似解决方案