循环修改一个字段,每次+1
循环修改一个字段,每次+1
Declare @Sort int,@ID int
Set @Sort = 0
Set @ID = 0
while(@Sort < (select Max(ID) from Table))
Begin
Set @Sort = @Sort + 1
Set @ID = @ID + 1
Update Table set Sort = @Sort where ID = @ID
End
go
Declare @Sort int,@ID int
Set @Sort = 0
Set @ID = 0
while(@Sort < (select Max(ID) from Table))
Begin
Set @Sort = @Sort + 1
Set @ID = @ID + 1
Update Table set Sort = @Sort where ID = @ID
End
go