Soldato
I need a little help with my Stored Procedure. I would like to iterate through a set of columns from a result and take each value and look up a corresponding value and then add all those together. The only way I can see of doing it, is by using separate variables for each week position and each weeks scores plus separate select statements. Can anyone help me? This obviously isn't good for scalibility And yes it is for the Poker League.
PKR_Tournament12 Table
PKR_Scoring Table
Thanks,
Blackvault
Code:
@pName varchar(50) = ''
AS
BEGIN
Declare @p1 int = 0
Declare @p2 int = 0
Declare @s1 int = 0
Declare @s2 int = 0
Declare @pUserID int = 0
Declare @pTotal int = 0
set @pUserID = (Select UserID from PKR_USERS where UserName = @pName)
set @p1 = (Select WEEK1POS From PKR_TOURNAMENT12)
set @p2 = (Select WEEK2POS From PKR_TOURNAMENT12)
set @s1 = (Select Points from PKR_SCORING where Position = @p1)
set @s2 = (Select Points from PKR_SCORING where Position = @p2)
set @pTotal = @s1 + @s2
Update PKR_RESULTS set points = @pTotal Where UserID = @pUserID
END
PKR_Tournament12 Table
Code:
[USERID][WEEK1POS][WEEK2POS]
1 1 1
PKR_Scoring Table
Code:
[Position][Points]
1 10
2 9
Thanks,
Blackvault