SQL Server 游标使用
时间:2021-07-01 10:21:17
帮助过:11人阅读
@index int;
declare @userId uniqueidentifier;
set @index=1;
declare user_cur
cursor for select UserId
from T_User
order by CreateTime
desc
open user_cur
fetch next from user_cur
into @userId
while (
@@FETCH_STATUS=0)
begin
update T_User
set Sort
=@index where UserId
=@userId;
set @index=@index+1;
fetch next from user_cur
into @userId
end
close user_cur;
deallocate user_cur;
参考链接:http://www.cnblogs.com/youngberry/archive/2009/07/17/1525647.html
SQL Server 游标使用
标签:code desc archive time sort cursor com index user