Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.49 KB | None | 0 0
  1. DECLARE @u_cPoints int, @c_creditPoints int;
  2. DECLARE cpoints_cursor CURSOR FOR
  3.     SELECT *
  4.     FROM CreditPoints, Users
  5.     WHERE CreditPoints.userId=Users.userId
  6. OPEN cpoints_cursor;
  7.  
  8. FETCH NEXT FROM cpoints_cursor
  9.     INTO @u_cPoints, @c_creditPoints;
  10.  
  11.     WHILE @@FETCH_STATUS = 0
  12.         BEGIN
  13.             UPDATE Users
  14.             SET Users.cPoints = Users.cPoints + @c_creditPoints;
  15.             FETCH NEXT FROM cpoints_cursor
  16.                 INTO @u_cPoints, @c_creditPoints;
  17.         END;
  18.     CLOSE cpoints_cursor
  19.     DEALLOCATE cpoints_cursor;
  20. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement