DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
DECLARE @ID int DECLARE @Val1 int DECLARE @Val2 int DECLARE #curr CURSOR LOCAL FAST_FORWARD READ_ONLY FOR SELECT ID, Value1, Value2 from Table1 OPEN #curr FETCH #curr INTO @ID, @Val1, @Val2 WHILE @@FETCH_Status=0 BEGIN UPDATE Table1 SET Summa=@Val1+@Val2 where ID=@ID FETCH #curr INTO @ID, @Val1, @Val2 END CLOSE #curr DEALLOCATE #curr
- UPDATE Table1 SET Summa = Value1 + Value2
Source: https://habr.com/ru/post/50155/