Advertisement
Guest User

Untitled

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