CREATE PROCEDURE _spMyProc
AS
DECLARE @MySum int
DECLARE @MyNum int
DECLARE @Id int
SET @MySum=0
DECLARE CurSum CURSOR FOR
SELECT MyNum,Id FROM Table1
OPEN CurSum
FETCH NEXT FROM CurSum INTO @MyNum ,@Id
WHILE @@FETCH_STATUS = 0
BEGIN
SET @MySum = @MySum + @MyNum
Update Table1 Set MySum = @MySum WHERE Id=@Id
FETCH NEXT FROM CurSum INTO @MyNum ,@Id
END
CLOSE CurSum
DEALLOCATE CurSum
/* SET NOCOUNT ON */
RETURN
|