如果我们需要SQL语句逐条更新每一条记录的值,应该如何操作呢?下面就将为您介绍SQL语句逐条更新的方法,供您参考
- -------------------------以下为逐条更新语句
- declare @i int
- declare @j int
- declare @ID int
- set @j=1
- select @i=count(*) from t_CaiWuTable05
- DECLARE t_CaiWuTable05_cursor CURSOR FOR SELECT AutoId FROM t_CaiWuTable05
- OPEN t_CaiWuTable05_cursor
- while @j<=@i
- begin
- FETCH NEXT FROM t_CaiWuTable05_cursor into @ID
- update t_CaiWuTable05 set ZJBL=rtrim('ZJBL'+cast(@j as char)) where AutoId=@ID
- set @j=@j+1
- end
- CLOSE t_CaiWuTable05_cursor
- DEALLOCATE t_CaiWuTable05_cursor
【编辑推荐】